hypha-rpc 0.21.42 → 0.21.44
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/coverage/html/index.html +1 -1
- package/dist/hypha-rpc-websocket.js +32 -16
- package/dist/hypha-rpc-websocket.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.js +1 -1
- package/dist/hypha-rpc-websocket.min.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.mjs +1 -1
- package/dist/hypha-rpc-websocket.min.mjs.map +1 -1
- package/dist/hypha-rpc-websocket.mjs +32 -16
- package/dist/hypha-rpc-websocket.mjs.map +1 -1
- package/package.json +1 -1
- package/src/websocket-client.js +32 -16
package/coverage/html/index.html
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
87
87
|
Code coverage generated by
|
|
88
88
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
89
|
-
at 2026-
|
|
89
|
+
at 2026-07-06T10:50:07.482Z
|
|
90
90
|
</div>
|
|
91
91
|
<script src="prettify.js"></script>
|
|
92
92
|
<script>
|
|
@@ -10424,6 +10424,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10424
10424
|
|
|
10425
10425
|
const MAX_RETRY = 1000000;
|
|
10426
10426
|
|
|
10427
|
+
// When the socket errors/closes during the handshake, wait briefly before
|
|
10428
|
+
// rejecting with the generic reason: the server usually sends a descriptive
|
|
10429
|
+
// {type:"error"} message (e.g. token/workspace mismatch) just before closing,
|
|
10430
|
+
// and on some runtimes (undici's native WebSocket on Node) the close is
|
|
10431
|
+
// surfaced BEFORE that message reaches onmessage. This grace lets the real
|
|
10432
|
+
// server reason win the race instead of a generic "error during handshake".
|
|
10433
|
+
const HANDSHAKE_ERROR_GRACE_MS = 100;
|
|
10434
|
+
|
|
10427
10435
|
class WebsocketRPCConnection {
|
|
10428
10436
|
constructor(
|
|
10429
10437
|
server_url,
|
|
@@ -10581,30 +10589,38 @@ class WebsocketRPCConnection {
|
|
|
10581
10589
|
|
|
10582
10590
|
// Handle WebSocket closing before connection_info is received.
|
|
10583
10591
|
// Without this, the promise hangs until the outer waitFor timeout (60s).
|
|
10592
|
+
// Defer the generic error/close rejection so a pending server
|
|
10593
|
+
// {type:"error"} message (handled in onmessage below) can settle first
|
|
10594
|
+
// with the actual reason. Without this, an undici close-as-error would
|
|
10595
|
+
// reject with "error during handshake" and hide the server's reason
|
|
10596
|
+
// (e.g. "workspace does not match"). If no descriptive message arrives
|
|
10597
|
+
// within the grace window, the generic rejection fires as a fallback.
|
|
10598
|
+
const rejectAfterGrace = (err) => {
|
|
10599
|
+
if (settled) return;
|
|
10600
|
+
setTimeout(() => {
|
|
10601
|
+
if (!settled) {
|
|
10602
|
+
settled = true;
|
|
10603
|
+
reject(err);
|
|
10604
|
+
}
|
|
10605
|
+
}, HANDSHAKE_ERROR_GRACE_MS);
|
|
10606
|
+
};
|
|
10607
|
+
|
|
10584
10608
|
const prevOnClose = this._websocket.onclose;
|
|
10585
10609
|
this._websocket.onclose = (event) => {
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
),
|
|
10592
|
-
);
|
|
10593
|
-
}
|
|
10610
|
+
rejectAfterGrace(
|
|
10611
|
+
new Error(
|
|
10612
|
+
`ConnectionAbortedError: WebSocket closed during handshake (code=${event.code}, reason=${event.reason || "unknown"})`,
|
|
10613
|
+
),
|
|
10614
|
+
);
|
|
10594
10615
|
// Delegate to any previously-set onclose handler
|
|
10595
10616
|
if (prevOnClose) prevOnClose.call(this._websocket, event);
|
|
10596
10617
|
};
|
|
10597
10618
|
|
|
10598
10619
|
const prevOnError = this._websocket.onerror;
|
|
10599
10620
|
this._websocket.onerror = (event) => {
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
new Error(
|
|
10604
|
-
`ConnectionAbortedError: WebSocket error during handshake`,
|
|
10605
|
-
),
|
|
10606
|
-
);
|
|
10607
|
-
}
|
|
10621
|
+
rejectAfterGrace(
|
|
10622
|
+
new Error(`ConnectionAbortedError: WebSocket error during handshake`),
|
|
10623
|
+
);
|
|
10608
10624
|
if (prevOnError) prevOnError.call(this._websocket, event);
|
|
10609
10625
|
};
|
|
10610
10626
|
|