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

handle exception when websocket server start room failed #289

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

jzhang20133
Copy link
Collaborator

@jzhang20133 jzhang20133 commented Apr 18, 2024

In this PR, we handle exception when websocket server start room failed by cleaning up fileLoader and room and user won't run into the two collaboration pop up due to websocket server task group inactive failure.
This PR also move authentication logic ahead of room initialization.

Resolving:
#291
#245

Copy link
Contributor

Binder 👈 Launch a Binder on branch jzhang20133/jupyter-collaboration/main-2

Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jzhang20133, could you please add a test that checks this logic?

self.log.info("Deleting file %s", file.path)
await self._file_loaders.remove(file_id)
self._emit(LogLevel.INFO, "clean", "Loader deleted.")
raise e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the exception be raised, or just logged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be raised when task group is not active and the request to set up websocket will fail and UI will retry. We should not fail silently here if task group is not active.

@jzhang20133
Copy link
Collaborator Author

@davidbrochart I have added a unit test to make sure two collaborative warning event is not thrown and room and file is deleted when both websocket requests fails due to webserver task group is no longer active.

@jzhang20133 jzhang20133 added enhancement New feature or request and removed bug Something isn't working labels Apr 25, 2024
@Zsailer
Copy link
Member

Zsailer commented Apr 25, 2024

Awesome work, @jzhang20133!

It looks like PR also fixes #291 by moving the prepare super call earlier in this override 🚀

@Zsailer
Copy link
Member

Zsailer commented Apr 25, 2024

@jzhang20133 thanks for this!

Just a minor comment about the prepare method. Does everything need to be under the condition that prepare is an awaitable?

Maybe a simpler approach is to call res = await ensure_async(super().prepare()).

@jzhang20133
Copy link
Collaborator Author

Addressed comments. @davidbrochart and @Zsailer would you like to review this PR again?

tests/test_handlers.py Outdated Show resolved Hide resolved
@jzhang20133 jzhang20133 force-pushed the main-2 branch 3 times, most recently from e6332b6 to be477fb Compare April 29, 2024 23:32
@Zsailer
Copy link
Member

Zsailer commented Apr 29, 2024

Looks great! Thanks @jzhang20133!

@jzhang20133 jzhang20133 merged commit 01ee5df into jupyterlab:main Apr 30, 2024
18 of 19 checks passed
Copy link
Collaborator

@davidbrochart davidbrochart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a follow-up to this PR would be to not handle exceptions directly here but in pycrdt-websocket using the exception handler.

self._websocket_server.add_room(self._room_id, self.room)
try:
await self._websocket_server.start_room(self.room)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, but didn't we introduced the YRoom exception handler just for that purpose? It seems we are bypassing all the work we did in pycrdt-websocket and instead directly handling the exception here.

try:
await super().stop()
except RuntimeError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in pycrdt-websocket using the exception handler.

try:
await super().stop()
except RuntimeError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in pycrdt-websocket using the exception handler.

jzhang20133 pushed a commit to jzhang20133/jupyter-collaboration that referenced this pull request May 1, 2024
jzhang20133 pushed a commit to jzhang20133/jupyter-collaboration that referenced this pull request May 1, 2024
jzhang20133 pushed a commit to jzhang20133/jupyter-collaboration that referenced this pull request May 1, 2024
jzhang20133 pushed a commit to jzhang20133/jupyter-collaboration that referenced this pull request May 1, 2024
Zsailer pushed a commit that referenced this pull request May 1, 2024
 (#298)

Co-authored-by: Jialin Zhang <jialin_zhang4@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants