Notification API WebSocket reconnection loop in Node.js

Building a custom reconnect handler for the notification service. The standard ws library handles the ping/pong, but I’m stuck on the retry backoff logic when the connection drops unexpectedly. Should I be polling for a new session ID before re-subscribing, or does the SDK handle that state internally? Here’s the current reconnect stub:

ws.on('close', () => {
 console.log('Connection closed');
 setTimeout(() => {
 // reconnect logic
 }, 5000);
});