You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an extension developer, I want to be able to access data providers from extensions I want to use without having weird timing issues that have nothing to do with my code or the other extension's code.
When Roopa wrote an extension ("Extension B") that uses a data provider registered by another extension ("Extension A"), she couldn't get the data provider in Extension B because it was activating before Extension A. We have lots of code that tries to mitigate timing issues (so this dependency would probably work across processes, but this is on the same process), but something is not working right with an extension getting a data provider before another extension activates and registers that provider. She kept getting the following error:
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Timeout reached when waiting for DataProvider-extensionTest.uidata to settle".] {
code: 'ERR_UNHANDLED_REJECTION'
}
When we wrapped the code getting the data provider in a 1-second setTimeout, the problem went away.
Seems there's a problem related to the AsyncVariables in the data provider service. Maybe some variable gets cached in get but isn't properly used in registerEngine or something. Note that the timeout is on DataProvider-extnesionTest.uidata, which seems to be related to the registerEngine.
Code Samples
Types in `paranext-ext-testing.d.ts` (Extension A)
setTimeout(async()=>{try{constdataProviderPromise1=papi.dataProvider.get<UICompDataProvider>('extensionTest.uidata');constuiDataProvider1=awaitdataProviderPromise1;logger.info('Extension Test UI Data provider : '+uiDataProvider1);constgreeting=awaituiDataProvider1?.sayHelloWithDataProvider('Tester');logger.info(Method${greeting});constdata=awaituiDataProvider1?.getUIData('*');if(data!==undefined){logger.info(ValuesreceivedfromgetUIDatainExt-Multiple-B${data.TextValue} States: ${data.States} Slider: ${data.Slider} Switch: ${data.Switch},);}else{logger.info('Did not get values in Ext-Multiple-B !!');}}catch(e){logger.info('Failed to get UIDataProvider',e);}},1000);
The text was updated successfully, but these errors were encountered:
After some testing of my own, I can say it looks like this is a problem when you have Extension B open in VS Code and are debugging while loading Extension A via --extensionDirs. However, if you are running the platform and have both Extension A and Extension B packaged and loaded using --extensionDirs, everything seems to work fine.
As an extension developer, I want to be able to access data providers from extensions I want to use without having weird timing issues that have nothing to do with my code or the other extension's code.
When Roopa wrote an extension ("Extension B") that uses a data provider registered by another extension ("Extension A"), she couldn't
get
the data provider in Extension B because it was activating before Extension A. We have lots of code that tries to mitigate timing issues (so this dependency would probably work across processes, but this is on the same process), but something is not working right with an extension getting a data provider before another extension activates and registers that provider. She kept getting the following error:When we wrapped the code getting the data provider in a 1-second
setTimeout
, the problem went away.Seems there's a problem related to the
AsyncVariable
s in the data provider service. Maybe some variable gets cached inget
but isn't properly used inregisterEngine
or something. Note that the timeout is onDataProvider-extnesionTest.uidata
, which seems to be related to theregisterEngine
.Code Samples
Types in `paranext-ext-testing.d.ts` (Extension A)
Accessing the data provider in Extension B
The text was updated successfully, but these errors were encountered: