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
I'm building a Jupyter frontend extension and I've created an in-progress notification for an async function similar to what's described in the notification example.
It works well but in my testing I've discovered what I believe is an edge case: The on-screen toast for the in-progress notification doesn't get updated despite the .reject() firing and the reject notification appearing in the notification center (instead of updating the on-screen toast). It appears to only happen once after the initial page load.
Reproduce
Load Jupyterlab with my extension enabled and auto-activated.
Trigger an in-progress notification with Notification.promise(PromiseDelegate, ...) that then instantly gets rejected with <PromiseDelegate>.reject(...) (e.g. in my case from an async function making an HTTP call which rejects its promise due to ERR_CONNECTION_REFUSED).
Observe the in-progress toast remains on screen without displaying the expected error from Notification.reject()[1]
Observe the toast in Step 3 continues to remain on-screen.
Observe that the Notification.reject() notification is actually shown in the notification center. [2]
[1]
[2]
Expected behavior
Load Jupyterlab with my extension enabled and auto-activated.
Trigger an in-progress notification with Notification.promise(PromiseDelegate, ...) that then instantly gets rejected (e.g. in my case due to the async function rejecting its promise due to ERR_CONNECTION_REFUSED) with <PromiseDelegate>.reject(...).
Observe the in-progress notification update to display an error. [3]
[3]
Context
While this only happens on the first in-progress notification after initial page load, there does not appear to be any correlation with how long after page load this happens. I've been able to reproduce it immediately after page load as well as a number of minutes afterward. After the first time it happens, successive (immediate) failures, as described above, successfully update the in-progress notification as expected.
Workaround
Introducing an artificial delay immediately before the PromiseDelegate.reject(...) call successfully prevents this issue (100ms seems to suffice). This leads me to believe there is something with the Notification system that is lazy loading or otherwise not immediately initializing.
Example
Initialize the promise
this._fetchToastPromiseDelegate = new PromiseDelegate<string>;
Notification.promise(this._fetchToastPromiseDelegate.promise, ...);
Add delay before rejection
} catch (err) {
await new Promise(f => setTimeout(f, 100));
this._fetchToastPromiseDelegate.reject("Error fetching results. Consult the console logs for details.");
httpErrorHandler(err);
The text was updated successfully, but these errors were encountered:
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋
Description
I'm building a Jupyter frontend extension and I've created an in-progress notification for an async function similar to what's described in the notification example.
It works well but in my testing I've discovered what I believe is an edge case: The on-screen toast for the in-progress notification doesn't get updated despite the
.reject()
firing and the reject notification appearing in the notification center (instead of updating the on-screen toast). It appears to only happen once after the initial page load.Reproduce
Notification.promise(PromiseDelegate, ...)
that then instantly gets rejected with<PromiseDelegate>.reject(...)
(e.g. in my case from an async function making an HTTP call which rejects its promise due toERR_CONNECTION_REFUSED
).Notification.reject()
[1]Notification.reject()
notification is actually shown in the notification center. [2][1]
![image](https://private-user-images.githubusercontent.com/1630311/292334184-7e5327ba-25a8-4da5-8e95-c55c1bb482db.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2NzA1NTQsIm5iZiI6MTcxODY3MDI1NCwicGF0aCI6Ii8xNjMwMzExLzI5MjMzNDE4NC03ZTUzMjdiYS0yNWE4LTRkYTUtOGU5NS1jNTVjMWJiNDgyZGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MThUMDAyNDE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmFhODVjY2NmOWMwYzBiMjcwYTMyNTY3YTc4ZjBmYTEwNjkxMGM5NmI4ZWM5YTkxNjcxMTY5N2U4MjcxMjRjZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.HbC0YSjO_hLNlFHPbjKM40I1t9s0y5wcLoXNrLjJrJI)
[2]
![image](https://private-user-images.githubusercontent.com/1630311/292334245-1233dd39-e457-4c08-b1fb-17acaf6afb83.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2NzA1NTQsIm5iZiI6MTcxODY3MDI1NCwicGF0aCI6Ii8xNjMwMzExLzI5MjMzNDI0NS0xMjMzZGQzOS1lNDU3LTRjMDgtYjFmYi0xN2FjYWY2YWZiODMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MThUMDAyNDE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjY5NzQzZWZkMjk4YjNmMWJlNmY4MmRmMTM1YmRhYmZkMDM5MWJiMDY5NTQyNjBjMzJjYmEzZGY4OGNjMjk4MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.87rOolwxU7pNWjPxL92YuzYN12hGNsYusw63OyuD9lc)
Expected behavior
Notification.promise(PromiseDelegate, ...)
that then instantly gets rejected (e.g. in my case due to the async function rejecting its promise due toERR_CONNECTION_REFUSED
) with<PromiseDelegate>.reject(...)
.[3]
![image](https://private-user-images.githubusercontent.com/1630311/292334587-4de96c84-dc22-40d9-b04f-985c5c01ec8c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2NzA1NTQsIm5iZiI6MTcxODY3MDI1NCwicGF0aCI6Ii8xNjMwMzExLzI5MjMzNDU4Ny00ZGU5NmM4NC1kYzIyLTQwZDktYjA0Zi05ODVjNWMwMWVjOGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MThUMDAyNDE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmViMTUzN2RjNjBlNzgzMGM1OGMyNGMyZDRhMzFjOGQ0NDc5ZjZkOGVkNzQ1ZjdjMzc0ZmU4OWRjM2JhMGE1MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.0TJXupaVgag_wZIjzW6bNtXUUeCiXLlLS_KSd4zUI4k)
Context
While this only happens on the first in-progress notification after initial page load, there does not appear to be any correlation with how long after page load this happens. I've been able to reproduce it immediately after page load as well as a number of minutes afterward. After the first time it happens, successive (immediate) failures, as described above, successfully update the in-progress notification as expected.
Workaround
Introducing an artificial delay immediately before the
PromiseDelegate.reject(...)
call successfully prevents this issue (100ms seems to suffice). This leads me to believe there is something with the Notification system that is lazy loading or otherwise not immediately initializing.Example
Initialize the promise
Add delay before rejection
The text was updated successfully, but these errors were encountered: