fix(session): classify transport and timeout errors as retryable#30638
fix(session): classify transport and timeout errors as retryable#30638literally-dan wants to merge 1 commit into
Conversation
5c2b49d to
fbeac4e
Compare
MessageV2.fromError previously only treated ECONNRESET as retryable and classified everything else (including transient transport failures) as a hard error. Broaden it so a network blip recovers instead of failing the session: - transient SystemError codes (ECONNRESET, ETIMEDOUT, ENOTFOUND, EAI_AGAIN, ECONNREFUSED, EHOSTUNREACH, ENETUNREACH, EPIPE) - DOMException TimeoutError (AbortSignal.timeout) - bare network-error Error messages (fetch failed, socket hang up, SSE read timed out, terminated, other side closed, ...) A bare AbortError stays a cancel (classified by error identity, not an external flag), so user cancellation is never retried. Verified with unit tests in message-v2.test.ts covering each code, message pattern, and the abort/timeout distinction.
fbeac4e to
c315f71
Compare
|
+1, really need this |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
I am not the PR's creator, but I request this PR be reopened. This PR is still an absolutely necessary resolution to a bug in OpenCode that causes tool calls to trigger an error and terminate agents. This PR is related to an open issue 30221 which still requires its resolution to be delivered. OpenCode, as it is now, is completely unreliable to use because once this bug occurs, the running session is unrecoverable. Any further tool calls, in the same session, will trigger the same error and termination 100% of the time. Automating the closing of such a valuable PR is completely unwise. You should not close PRs simply because the OpenCode team has yet to have time to review and approved/reject them, for existing an open bug. |
|
I've rebased this PR and think it should be reopened. It solves an existing bug that's really annoying when dealing with subagents. |
|
Rebased and refreshed the source branch against current |
Issue for this PR
Closes #30611
Type of change
What does this PR do?
MessageV2.fromErroronly markedECONNRESETas retryable and treated every other transport failure as a hard error. This widens it to cover the common transient cases:ECONNRESET,ETIMEDOUT,ENOTFOUND,EAI_AGAIN,ECONNREFUSED,EHOSTUNREACH,ENETUNREACH,EPIPE)TimeoutErrorfromAbortSignal.timeoutfetch failed,socket hang up,terminated,other side closed, and similar)A bare
AbortErrorstays a cancel, classified by the error itself rather than an external flag, so a user cancelling a turn is never retried.How did you verify your code works?
Unit tests in
message-v2.test.tscover each system code, each message pattern, theTimeoutErrorcase, and the cancel-vs-timeout distinction.bun typecheckpasses.Screenshots / recordings
Not applicable.
Checklist