Skip to content

fix(core): fall back on oversized websocket requests - #43099

Merged
neriousy merged 1 commit into
devfrom
websocket-1009-fallback
Aug 17, 2026
Merged

fix(core): fall back on oversized websocket requests#43099
neriousy merged 1 commit into
devfrom
websocket-1009-fallback

Conversation

@neriousy

@neriousy neriousy commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detect WebSocket close code 1009 as a transport size failure
  • retry the rejected request immediately over HTTP and keep the session on HTTP
  • preserve the existing retry budget for transient WebSocket closes

Fixes #42572

Reproduction

Requires ffmpeg and OpenAI authentication. From the repository root:

ffmpeg -y -loglevel error \
  -f lavfi -i "nullsrc=s=1920x1080:r=1,noise=alls=100:allf=t+u" \
  -frames:v 6 /tmp/opencode-ws-%d.png

cd packages/opencode
OPENCODE_EXPERIMENTAL_WEBSOCKETS=true bun run src/index.ts run \
  "Reply with only: received" \
  --pure --print-logs --log-level DEBUG --auto \
  --model openai/gpt-5.6-sol \
  -f /tmp/opencode-ws-{1..6}.png

On unpatched dev, this produces five ProviderResponseStreamError failures with code 1009: message too big before HTTP fallback succeeds. With this change, the same request immediately falls back to HTTP and returns the normal streamed response.

Testing

  • bun test test/plugin/openai-ws.test.ts
  • bun typecheck
  • bunx prettier --check src/plugin/openai/ws.ts src/plugin/openai/ws-pool.ts test/plugin/openai-ws.test.ts

@neriousy neriousy changed the title fix(openai): fall back on oversized websocket requests fix(core): fall back on oversized websocket requests Aug 17, 2026
@neriousy neriousy self-assigned this Aug 17, 2026
@neriousy
neriousy requested a review from rekram1-node August 17, 2026 17:55
@neriousy
neriousy enabled auto-merge (squash) August 17, 2026 18:34
@neriousy
neriousy disabled auto-merge August 17, 2026 18:35
@neriousy
neriousy merged commit 7af274a into dev Aug 17, 2026
15 of 17 checks passed
@neriousy
neriousy deleted the websocket-1009-fallback branch August 17, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI WebSocket 1009 retries the same oversized response.create five times before HTTP fallback

1 participant