Building a Node.js listener for the Notification API to capture events for OpenTelemetry tracing. The standard reconnect logic on close or error events isn’t preserving the context across the new connection, causing trace gaps. Here’s the relevant snippet:
ws.on('close', () => {
console.log('Connection lost, reconnecting...');
setTimeout(() => connect(), 2000);
});
The new WebSocket instance gets a fresh connection ID, but the server-side session seems to stale. Is there a specific header or query param needed to maintain session continuity for tracing purposes?