-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Use proper status codes #105
Comments
I think we’d need to improve the client to handle those errors. |
When the hocuspocus Unfortunately, the original y-websocket doesn't pass the WebSocket CloseEvent. I’ve fiddled around with a fork of y-websocket to play around with a few ideas, like this one here. The first rough version is available on npm. import { HocuspocusProvider } from '@hocuspocus/provider'
const provider = new HocuspocusProvider({
url: 'ws://127.0.0.1:1234',
name: 'hocuspocus-demo',
document: this.ydoc,
onClose: ({ event }) => {
console.log('[close]', event.code, event.reason)
},
})
// Output: [close] 4403 Forbidden That lets you act accordingly, for example when a user isn’t authorized to connect. I have a few more ideas for the provider and implemented already a few things, but I’m still not sure how far I’ll take that. For now it’s still compatible with all other Y.js providers, just with a few more features and I’d like to keep it that way. It’s likely that I sent a PR for the status codes to y-websocket once it’s proven to be helpful. One thing though: Play around with it and send your feedback, but don’t use it in production. It’s the first release, and probably has a few bugs. |
I think we’re not using status codes for the close event right now. Leaving this here as a note to check what we’re doing now, and if we can improve that.
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
The text was updated successfully, but these errors were encountered: