fix: use server.close() for SSE reconnection and guard connect() failure #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-sse-reconnection-robust"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
server.close()instead oftransport.close()— the SDK'sProtocol.connect()throws ifthis._transportis still set._transportis only cleared insideProtocol._onclose(), which fires via the transport'sonclosecallback. Callingtransport.close()directly risks leaving_transportset ifclose()throws beforeonclosefires;server.close()is the correct SDK cleanup path.catch {}.server.connect()with a try/catch that returns HTTP 500 and clears the local transport ref if the connect fails, rather than letting the SSE response hang indefinitely.src/server.test.tsusingInMemoryTransport: explicitserver.close()→ re-connect, and client-initiated disconnect → re-connect.Test plan
npm test— all 130 tests pass including the two new reconnection tests