Skip to content

effect(server): typed errors in session/sync handlers, fix concurrency#27146

Merged
kitlangton merged 1 commit into
devfrom
effect/server-handler-typed-errors
May 14, 2026
Merged

effect(server): typed errors in session/sync handlers, fix concurrency#27146
kitlangton merged 1 commit into
devfrom
effect/server-handler-typed-errors

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Summary

Small server-handler cleanups under packages/opencode/src/server/routes/instance/httpapi/:

  • handlers/session.ts:376 — Part-mismatch raw throw new Error(...) in updatePart replaced with return yield* new HttpApiError.BadRequest({}). The endpoint already declares HttpApiError.BadRequest in its error union, so the wire format is unchanged from the existing 400 convention used by sibling handlers.
  • handlers/sync.ts:62throw new Error("Cannot steal session without workspace context") replaced with return yield* new HttpApiError.BadRequest({}). The sync.steal endpoint already declares HttpApiError.BadRequest.
  • handlers/instance.ts:41Effect.all([vcs.branch(), vcs.defaultBranch()], { concurrency: 2 }) changed to { concurrency: "unbounded" } (two unrelated queries).
  • handlers/session.ts:153,204 — Extracted a file-local tryParseJson(text) helper, since both createRaw and forkRaw had identical Effect.try blocks wrapping JSON.parse(body) with the same HttpApiError.BadRequest mapping.

Test plan

  • bun run typecheck from packages/opencode
  • bun run test test/server/httpapi-session.test.ts test/server/httpapi-sync.test.ts test/server/httpapi-instance.test.ts (17 pass, 1 todo)

- session.updatePart: raw throw -> HttpApiError.BadRequest
- sync.steal: raw throw -> HttpApiError.BadRequest
- instance.vcs: Effect.all concurrency 2 -> "unbounded"
- session.ts: extract tryParseJson helper for createRaw/forkRaw
@kitlangton kitlangton force-pushed the effect/server-handler-typed-errors branch from 9726181 to 697f4f8 Compare May 13, 2026 23:41
@kitlangton kitlangton marked this pull request as ready for review May 13, 2026 23:48
@kitlangton kitlangton merged commit 3f33be1 into dev May 14, 2026
8 of 9 checks passed
@kitlangton kitlangton deleted the effect/server-handler-typed-errors branch May 14, 2026 00:31
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant