Skip to content

fix: drain tee stream queues in linear time - #2379

Merged
HAYDEN-OAI merged 1 commit into
mainfrom
agent/linear-stream-tee-queues
Aug 17, 2026
Merged

HAYDEN-OAI merged 1 commit into
mainfrom
agent/linear-stream-tee-queues

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • replace per-branch Array.shift() queues in public Stream.tee() with compact head-index queues that release consumed promises and periodically reclaim buffered storage
  • preserve shared source promises, event ordering, independent reader speeds, source errors/completion, and explicit shared-controller cancellation
  • add regression-first public streaming coverage for lag in both directions, bounded array movement and memory retention, interleaving, concurrent reads, and exact source-pull counts

Verification

  • reproduced 8,386,560 shifted element positions when draining 4,096 buffered events before the fix
  • 71 focused streaming and queue tests
  • 2,957 handwritten unit tests across 98 files
  • changed-file formatter and all 415 lint rules
  • repository TypeScript checks, CommonJS/ESM build, published TypeScript 4.9/current checks, and packed-package verification

@openai-sdks

openai-sdks Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

OkTest Summary

✅ 237/237 SDK tests passed in 10.141s for Node SDK PR #2379.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 151ms
tests/chat-completions-create.test.ts ✅ Passed 227ms
tests/chat-completions-stream.test.ts ✅ Passed 197ms
tests/files-content-binary.test.ts ✅ Passed 178ms
tests/files-create-multipart.test.ts ✅ Passed 125ms
tests/files-list-pagination.test.ts ✅ Passed 140ms
tests/initialize-config.test.ts ✅ Passed 169ms
tests/instance-isolation.test.ts ✅ Passed 93ms
tests/models-list.test.ts ✅ Passed 133ms
tests/responses-background-lifecycle.test.ts ✅ Passed 232ms
tests/responses-body-method-errors.test.ts ✅ Passed 337ms
tests/responses-cancel-timeout.test.ts ✅ Passed 199ms
tests/responses-cancel.test.ts ✅ Passed 200ms
tests/responses-compact-retries.test.ts ✅ Passed 229ms
tests/responses-compact.test.ts ✅ Passed 184ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 119ms
tests/responses-create-advanced.test.ts ✅ Passed 162ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.151s
tests/responses-create-errors.test.ts ✅ Passed 201ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 171ms
tests/responses-create-retries.test.ts ✅ Passed 236ms
tests/responses-create-stream-failures.test.ts ✅ Passed 192ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.157s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.519s
tests/responses-create-stream.test.ts ✅ Passed 76ms
tests/responses-create-terminal-states.test.ts ✅ Passed 246ms
tests/responses-create-timeout.test.ts ✅ Passed 201ms
tests/responses-create.test.ts ✅ Passed 165ms
tests/responses-delete.test.ts ✅ Passed 272ms
tests/responses-input-items-errors.test.ts ✅ Passed 199ms
tests/responses-input-items-list.test.ts ✅ Passed 182ms
tests/responses-input-items-options.test.ts ✅ Passed 117ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 219ms
tests/responses-input-tokens-count.test.ts ✅ Passed 211ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.232s
tests/responses-not-found-errors.test.ts ✅ Passed 299ms
tests/responses-parse.test.ts ✅ Passed 191ms
tests/responses-retrieve-retries.test.ts ✅ Passed 233ms
tests/responses-retrieve.test.ts ✅ Passed 202ms
tests/responses-stored-method-errors.test.ts ✅ Passed 533ms
tests/retry-behavior.test.ts ✅ Passed 2.892s
tests/sdk-error-shape.test.ts ✅ Passed 263ms

View OkTest run #32065814956

SDK merge (e11c9309b7e1) · head (a9dc292fa777) · base (5b96016f2360) · OkTest (7e7850017529)

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the exact head in two independent passes. The head-index queue preserves tee ordering, shared promise identity, pull counts, completion/rejection, cancellation, and existing backpressure semantics while making dequeue amortized O(1) and releasing consumed references promptly. Focused tests and exact-head CI are clean.

@HAYDEN-OAI
HAYDEN-OAI added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit 1f3ce07 Aug 17, 2026
27 checks passed
@HAYDEN-OAI
HAYDEN-OAI deleted the agent/linear-stream-tee-queues branch August 17, 2026 21:35
@openai-sdks openai-sdks Bot mentioned this pull request Aug 17, 2026

This branch was previously deployed

1 inactive deployment
ci — a9dc292f Deployed Aug 17, 2026 by HAYDEN-OAI via ecosystem tests #8254
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.

2 participants