dotnet/runtime · error · Error
No active session to reconnect
Error message
No active session to reconnect
What it means
Thrown by `connectDSRouter` when there is no existing `serverSession` to migrate. The function's purpose is to take over an already established diagnostic session and redirect it to a new WebSocket URL (e.g. switching to dotnet-dsrouter); without a live session there is nothing to reconnect.
Solutions
- Wait until `serverSession` exists (the runtime has advertised) before calling `connectDSRouter`.
- Do not call `connectDSRouter` after the diagnostic session was closed; re-establish one first.
- Ensure diagnostics are enabled in the runtime so an advert is produced.
Example fix
// before: no session yet
connectDSRouter('ws://localhost:8080'); // throws
// after: wait for the session, then switch the router
await waitForDiagSession();
connectDSRouter('ws://localhost:8080'); Defensive patterns
Strategy: validation
Validate before calling
function canConnectDSRouter () {
return !!serverSession;
}
if (canConnectDSRouter()) connectDSRouter(url); Type guard
function hasSessionToReconnect (): boolean {
return typeof serverSession !== 'undefined' && serverSession !== null;
} Prevention
- Call `connectDSRouter` only after the runtime has advertised a session.
- Do not call it after the diagnostic session was closed.
- Enable diagnostics so an advert is produced.
When it happens
Trigger: Calling `connectDSRouter(url)` (index.ts:82) before the runtime has advertised a diagnostic session, or after the session was closed. The guard at index.ts:83-85 fires because `serverSession` is undefined.
Common situations: Calling `connectDSRouter` at startup before the advert arrives; calling it after the prior session ended; runtime published without diagnostics.
Related errors
- No active session to reconnect
- multiple clients in parallel are not allowed
- No active JS diagnostic session
- No active JS diagnostic session
- No active JS diagnostic session
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/443f26f7eda54bd9.
Report an issue: GitHub.
Appendix: source
Thrown at src/mono/browser/runtime/diagnostics/index.ts:84
return -1;
}
socket_handles.delete(client_socket);
return wrapper.close();
};
globalObjects.api.collectCpuSamples = collectCpuSamples;
globalObjects.api.collectMetrics = collectMetrics;
globalObjects.api.collectGcDump = collectGcDump;
globalObjects.api.connectDSRouter = connectDSRouter;
cleanup_js_client();
}
// this will take over the existing connection to JS and send new advert message to WS client
// use dotnet-dsrouter server-websocket -v trace
function connectDSRouter (url: string): void {
if (!serverSession) {
throw new Error("No active session to reconnect");
}
// make sure new sessions hit the new URL
url_override = url;
const wrapper = createDiagConnectionWs(serverSession.client_socket, url);
socket_handles.set(serverSession.client_socket, wrapper);
wrapper.send(advertise());
}
View on GitHub (pinned to 60108ba66e)