@glassly/cloud-protocol 0.3.1-dev.538 → 0.3.1-dev.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/errors.ts +13 -0
package/package.json
CHANGED
package/src/errors.ts
CHANGED
|
@@ -19,6 +19,19 @@ export const PROTOCOL_ERROR_CODES = {
|
|
|
19
19
|
|
|
20
20
|
export type ProtocolErrorCode = keyof typeof PROTOCOL_ERROR_CODES;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* WebSocket close codes for closes the runtime initiates. Application range
|
|
24
|
+
* (4000–4999) on purpose: iOS's SocketRocket treats 1012–1015 as invalid and
|
|
25
|
+
* raises a protocol error before it parses the reason, so a client closed with
|
|
26
|
+
* 1012 saw a bare code (or "Stream end encountered") and could not tell a
|
|
27
|
+
* supersede from a network drop — two phones on one account then took the
|
|
28
|
+
* session from each other every second.
|
|
29
|
+
*/
|
|
30
|
+
export const WS_CLOSE_CODES = {
|
|
31
|
+
SUPERSEDED: 4001, // a newer session for this user won; do not reconnect
|
|
32
|
+
OWNERSHIP_LOST: 4002, // this runtime instance lost the session; reconnect
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
22
35
|
export const protocolErrorPayloadSchema = z.object({
|
|
23
36
|
code: z.string(), // a ProtocolErrorCode or a service-defined code
|
|
24
37
|
message: z.string(),
|