Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer Jupyter Comm initialization until frontend is ready #6229

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Jan 18, 2024

This resolves an issue when there is a race condition between the frontend being fully initialized (i.e. Bokeh and Panel JS and all extensions being loaded) and the backend trying to send an event to the frontend. This could occur if a user loaded the extension, rendered some component and then sent a message to it in rapid succession. Sending a message to the frontend would automatically attempt to open a Comm but if the frontend wasn't ready this Comm would never connect and we'd end up with a completely dead Comm, i.e. no messages could be sent across it.

This PR resolves this issue by waiting on the frontend to open the so called client comm, which indicates that the frontend is fully initialized. Only once the client comm is open we initialize the server comm. If a user attempts to send an event across the unopened server comm we schedule the message on the event loop until the comm has successfully been initialized.

Fixes #6178

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (c8f4e08) 82.68% compared to head (56ce133) 84.16%.
Report is 3 commits behind head on main.

Files Patch % Lines
panel/io/notebook.py 46.15% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6229      +/-   ##
==========================================
+ Coverage   82.68%   84.16%   +1.48%     
==========================================
  Files         301      301              
  Lines       45099    45110      +11     
==========================================
+ Hits        37288    37967     +679     
+ Misses       7811     7143     -668     
Flag Coverage Δ
ui-tests 40.71% <30.76%> (+2.23%) ⬆️
unitexamples-tests 71.84% <46.15%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

panel/io/notebook.py Show resolved Hide resolved
panel/template/base.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notification initialisation is not properly working
2 participants