| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR fixes two latent startup-path bugs in src/session.ts reported in #5521. Previously, if getVersionDetails() timed out, the cancellation token rejection would throw out of start() and bypass the intended "Unable to get version details!" failure handling. Additionally, connectFunc had no error or timeout handlers, meaning a stalled named-pipe or socket connection would hang indefinitely.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/session.ts | Adds try/catch/finally to getVersionDetails() for graceful timeout handling with proper resource cleanup; adds error handler and 60s timeout to connectFunc for stalled connections. |
| test/core/session.test.ts | Adds describe("SessionManager.getVersionDetails") test suite with two tests and shared helper functions (makeManager, setSendRequest, getVersionDetails). |
Sorry, something went wrong.
Two latent startup-path bugs in `src/session.ts`, surfaced while investigating #5031 (neither caused it): - `getVersionDetails()` set a 60s timeout that only cancelled the token, so when it fired `sendRequest(...)` rejected and the `await` threw straight out of `start()` — the intended graceful failure handling was never reached. We now catch the rejection, log the underlying cause as a warning, and return `undefined` so the existing failure branch runs and surfaces a friendlier, more actionable message to the user. While here, fix the timer leak: we capture the `setTimeout` handle to `clearTimeout` it and `dispose()` the `CancellationTokenSource`. - `connectFunc` had no error or timeout handler, so a transport that never connected just hung with nothing actionable. We add an `error` handler and a 60s connect timeout that destroys the socket and rejects with a clear, logged message naming the pipe. Both paths clear the timer so a healthy but idle connection is never torn down. Adds unit tests for `getVersionDetails()` covering the reject-to- `undefined` path and the normal fast path. `connectFunc` is a private closure over a live `net` socket with no test seam, so I left it uncovered rather than add socket-mocking infra the repo deliberately avoids. Closes #5521. Drafted by Copilot (Claude Opus 4.8). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Tests pass on my machine. not sure if anyone ever hit this deadlock but a good find.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes the two latent startup-path bugs in src/session.ts reported in #5521 (surfaced while investigating #5031; neither caused it).
1. getVersionDetails() timeout threw out of start()
The 60s timeout only cancelled the token, so when it fired sendRequest(...) rejected and the await threw straight out of start() — the intended "Unable to get version details!" handling was never reached. It now catches the rejection, logs it via ILogger, and returns undefined so the existing if (versionDetails === undefined) failure branch runs. Also fixes the original timer leak: the setTimeout handle is captured and clearTimeout'd, and the CancellationTokenSource is dispose()d in finally.
2. connectFunc had no error/timeout handler
A transport that never connected just hung with nothing actionable. Adds an error handler and a 60s connect timeout that destroy()s the socket and rejects with a clear, logged message naming the pipe. Both paths clearTimeout so a healthy but idle connection is never torn down. Works whether the transport is a named pipe or a socket.
Tests
Adds describe("SessionManager.getVersionDetails") in test/core/session.test.ts covering the reject-to-undefined path and the normal fast path. connectFunc is a private closure over a live net socket with no test seam, so it's left uncovered rather than adding socket-mocking infra the repo deliberately avoids.
Verification
Closes #5521.
🤖 Drafted by GitHub Copilot (Claude Opus 4.8) at Andy Jordan (@andyleejordan)'s request.