fix: Multiplayer close retry (#10638)

This commit is contained in:
Tom Moor
2025-11-13 20:25:18 -05:00
committed by GitHub
parent c2762ce087
commit 8e95f13793
2 changed files with 33 additions and 1 deletions
@@ -157,7 +157,11 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
provider.on("close", (ev: MessageEvent) => {
if ("code" in ev.event) {
// Note other close code are handled internally by the library
if (ev.event.code === EditorUpdateError.code) {
provider.shouldConnect = false;
}
ui.setMultiplayerStatus("disconnected", ev.event.code);
if (ev.event.code === EditorUpdateError.code) {
+28
View File
@@ -1,24 +1,52 @@
/**
* The server is terminating the connection because a data frame was received
* that is too large.
* See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
*/
export const DocumentTooLarge = {
code: 1009,
reason: "Document Too Large",
};
/**
* Similar to AuthorizationFailed, but specifically for use when authentication is required and has
* failed or has not yet been provided.
*/
export const AuthenticationFailed = {
code: 4401,
reason: "Authentication Failed",
};
/**
* The request contained valid data and was understood by the server, but the server
* is refusing action.
*/
export const AuthorizationFailed = {
code: 4403,
reason: "Authorization Failed",
};
/**
* The server is refusing to process the request because there are too many connections
* to the given document.
*/
export const TooManyConnections = {
code: 4503,
reason: "Too Many Connections",
};
/**
* The client must update their editor to continue collaborating.
*/
export const EditorUpdateError = {
code: 4999,
reason: "Editor Update Required",
};
/**
* The server timed out waiting for the request.
*/
export const ConnectionTimeout = {
code: 4408,
reason: "Connection Timeout",
};