Fix WebCRT sessions killed by StrictMode ws_ticket reuse.

Allow short-lived tickets multiple uses, stop deleting PTY on transient websocket errors, and avoid marking connect complete after a dropped wait loop.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-02 18:49:29 +08:00
parent b42f4eb588
commit 9314f11ce7
4 changed files with 62 additions and 17 deletions

View file

@ -2341,14 +2341,19 @@ export function WebcrtPage() {
void openTarget(tab.target, { force: true });
return;
}
// Transient browser WS failures (StrictMode remount / ticket race) must
// NOT delete the device PTY — keep session_id for reconnect/reattach.
const transientWs =
/^(websocket_error|websocket_closed)/i.test(String(message || "")) ||
String(message || "").toLowerCase().includes("websocket");
updateTab(tab.key, {
status: "error",
sessionId: "",
wsUrl: "",
status: transientWs ? "closed" : "error",
sessionId: transientWs ? tab.sessionId : "",
wsUrl: transientWs ? tab.wsUrl : "",
connectPhase: undefined,
errorMessage: webcrtErrorMessage(errMsg, t),
});
if (sid) {
if (sid && !transientWs) {
void closeWebcrtSession(sid).catch(() => undefined);
}
if (isInventoryTarget(tab.target) && isSshAuthFailure(errMsg)) {