Repository navigation
fix(server): keep OpenCode timeouts from crashing the error formatter #12469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tachytelicdetonation
wants to merge
4
commits into
pingdotgg:main
Choose a base branch
from
tachytelicdetonation:fix/opencode-runtime-error-detail
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+209
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7bb99e2
fix(server): keep OpenCode timeouts from crashing the error formatter
tachytelicdetonation e777a3b
test(server): wait on the prompt signal instead of polling
tachytelicdetonation 3b7d255
docs(server): describe the contract of openCodeRuntimeErrorDetail
tachytelicdetonation 7c67a7d
test(server): cover the prompt-timeout plus abort-timeout sequence
tachytelicdetonation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
apps/server/src/provider/opencodeRuntime.errorDetail.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import * as NodeAssert from "node:assert/strict"; | ||
|
|
||
| import * as Cause from "effect/Cause"; | ||
| import { describe, it } from "vite-plus/test"; | ||
|
|
||
| import { OpenCodeRuntimeError, openCodeRuntimeErrorDetail } from "./opencodeRuntime.ts"; | ||
|
|
||
| describe("openCodeRuntimeErrorDetail", () => { | ||
| it("formats an Effect TimeoutError constructed without a message", () => { | ||
| const detail = openCodeRuntimeErrorDetail(new Cause.TimeoutError()); | ||
| NodeAssert.equal(typeof detail, "string"); | ||
| NodeAssert.match(detail, /TimeoutError/); | ||
| }); | ||
|
|
||
| it("returns the detail of an OpenCodeRuntimeError", () => { | ||
| const error = new OpenCodeRuntimeError({ operation: "session.abort", detail: "aborted" }); | ||
| NodeAssert.equal(openCodeRuntimeErrorDetail(error), "aborted"); | ||
| }); | ||
|
|
||
| it("returns a trimmed Error message", () => { | ||
| NodeAssert.equal(openCodeRuntimeErrorDetail(new Error(" timed out ")), "timed out"); | ||
| }); | ||
|
|
||
| it("does not throw for an Error whose message is undefined", () => { | ||
| // Effect's TimeoutError constructed without an argument arrives this way. | ||
| const error = new Error("placeholder"); | ||
| Object.defineProperty(error, "message", { value: undefined, writable: true }); | ||
| const detail = openCodeRuntimeErrorDetail(error); | ||
| NodeAssert.equal(typeof detail, "string"); | ||
| NodeAssert.ok(detail.length > 0); | ||
| }); | ||
|
|
||
| it("does not throw for an Error whose message is not a string", () => { | ||
| const error = new Error("placeholder"); | ||
| Object.defineProperty(error, "message", { value: { code: 42 }, writable: true }); | ||
| const detail = openCodeRuntimeErrorDetail(error); | ||
| NodeAssert.equal(typeof detail, "string"); | ||
| NodeAssert.ok(detail.length > 0); | ||
| }); | ||
|
|
||
| it("falls through to the object fallback for an Error with an empty message", () => { | ||
| const error = Object.assign(new Error(""), { response: { status: 503 }, error: "down" }); | ||
| NodeAssert.equal(openCodeRuntimeErrorDetail(error), 'status=503 body="down"'); | ||
| }); | ||
|
|
||
| it("formats SDK response shapes", () => { | ||
| NodeAssert.equal( | ||
| openCodeRuntimeErrorDetail({ response: { status: 500 }, error: { message: "boom" } }), | ||
| 'status=500 body={"message":"boom"}', | ||
| ); | ||
| }); | ||
|
|
||
| it("stringifies primitives", () => { | ||
| NodeAssert.equal(openCodeRuntimeErrorDetail("plain"), "plain"); | ||
| NodeAssert.equal(openCodeRuntimeErrorDetail(undefined), "undefined"); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
provider/opencodeRuntime.ts:126This formatter throws instead of returning a diagnostic when an
Errorsubclass changes or throws on its secondmessagegetter access. Thetypeofcheck and subsequent.trim()readcause.messageseparately; read it once into a local before checking and trimming.🤖 Copy this AI Prompt to have your agent fix this: