Skip to content

Add message error handler#144

Merged
krassowski merged 3 commits into
y-crdt:mainfrom
krassowski:add-message-error-handler
Jun 1, 2026
Merged

Add message error handler#144
krassowski merged 3 commits into
y-crdt:mainfrom
krassowski:add-message-error-handler

Conversation

@krassowski
Copy link
Copy Markdown
Member

See jupyterlab/jupyter-collaboration#584 (comment)

There already is exception_handler but it is only for logging - it is called after catching the exception and stoping the room. The use case here is different - we want to be able to continue the room execution.

Modelled on on_message property/setter pattern.

@krassowski krassowski added the enhancement New feature or request label May 31, 2026
Comment thread src/pycrdt/websocket/yroom.py Outdated
"""
Returns:
The optional callback to call when an exception is raised while processing
a sync message. The callback receives the exception, the raw message bytes,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that this handler should be called for any message type, not just a sync message.

_handled = self._on_message_error(exc, message, channel)
handled = await _handled if isawaitable(_handled) else _handled
if handled:
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like we can have this logic once for all message types just after async for message in channel:, instead of duplicating it for all message types?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Like 8c0a645?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this looks good.

@krassowski krassowski merged commit 7e06347 into y-crdt:main Jun 1, 2026
20 checks passed
@krassowski krassowski deleted the add-message-error-handler branch June 1, 2026 14:12
@krassowski
Copy link
Copy Markdown
Member Author

Can we release next version? Should it be 0.17.0?

@davidbrochart
Copy link
Copy Markdown
Contributor

I released v0.16.2.

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.

2 participants