fix(net): offline hangs, stderr discipline, loopback callback bind - #241
Merged
Conversation
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Four verified network-robustness + output-discipline fixes.
statusno longer hangs ~10s on packet-drop networks.checkEndpoint(status-info) andfetchCliLatest(update-check) usedfetch+AbortSignal.timeout, where undici keeps a ref'd ~10s connect timer alive after abort and stalls process exit. Extracted the repo's existing node:https + unref'd-timer pattern into a sharedfetchJsonUnref(url, timeoutMs)(newsrc/lib/http.ts) and routed both callers plusupdate-cache.fetchLatestVersionthrough it.postActionhint (cli.ts) andwarnDaemonMismatch(status.ts) now print to stderr viaconsole.error, soagentage memory read x.md > out.txtstays clean.server.listen(0, '127.0.0.1', ...)instead of all interfaces - the one-shot sign-in callback is no longer LAN-reachable.authedGet/authedPostsetredirect: 'manual'so the bearer is never replayed to a redirect target;authedGettreats any 3xx (or opaqueredirect) as an error and reports the status.setup --disconnectrevoke can't stall.revokeTokengetsAbortSignal.timeout(3000)(configurable for tests). It's a POST so it stays on global fetch rather than the GET-only shared helper; residual undici keepalive is acceptable there since the process exits right after and errors are already swallowed.Why
Offline/packet-drop machines saw
statusandsetup --disconnectblock for ~10s; piped reads got polluted by the update hint; the sign-in callback and bearer-bearing redirects were needless attack surface.Tests
http.test.ts(unreachable host resolves null within bound).update-check/status-infotests re-pointed at the mocked helper;api.test.tsassertsredirect: 'manual'and a new 302-refused case;oauth.test.tsasserts a stalled revoke aborts within the timeout;callback-server.test.tsasserts loopback reachability.Scope
Touched only the postAction hook in cli.ts (kept surgical for the sibling Node-version-guard PR). Did not touch memory.ts, vault-sync, file-lock, or daemon files.
Verified: npm run verify green locally.