Skip to content

fix(shared): stop Queue.pull treating undefined as the empty sentinel - #50

Merged
dinwwwh merged 1 commit into
mainfrom
claude/queue-undefined-sentinel-shift-eda977
Aug 3, 2026
Merged

fix(shared): stop Queue.pull treating undefined as the empty sentinel#50
dinwwwh merged 1 commit into
mainfrom
claude/queue-undefined-sentinel-shift-eda977

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 3, 2026

Copy link
Copy Markdown
Member

Queue.pull() shifted the buffer first and then tested the result against undefined, so a legitimately buffered undefined value was consumed and discarded while the pull parked despite later buffered items — the value was lost and pull ordering inverted. pull() now checks the buffer length before shifting, matching push(), which already hands undefined straight to a waiting resolver.

Fixes

  • Queue<string | undefined> (and similar) no longer loses pushed undefined values; pulls return them in order instead of parking.
  • Latent in-repo: all current consumers use non-optional element types, but Queue is publicly exported with unconstrained T, so external consumers were exposed.

Testing

  • New regression test: push(undefined) then push('a') pulls back undefined then 'a' in order.
  • All 9 queue tests pass.

pull() shifted first and tested the result against undefined, so a
legitimately buffered undefined value was consumed, discarded, and the
pull parked despite later buffered items. Check items.length before
shifting instead, matching push(), which already hands undefined to a
waiting resolver.
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown
@standardserver/aws-lambda

npm i https://pkg.pr.new/@standardserver/aws-lambda@50

@standardserver/bun

npm i https://pkg.pr.new/@standardserver/bun@50

@standardserver/core

npm i https://pkg.pr.new/@standardserver/core@50

@standardserver/deno

npm i https://pkg.pr.new/@standardserver/deno@50

@standardserver/fastify

npm i https://pkg.pr.new/@standardserver/fastify@50

@standardserver/fetch

npm i https://pkg.pr.new/@standardserver/fetch@50

@standardserver/node

npm i https://pkg.pr.new/@standardserver/node@50

@standardserver/peer

npm i https://pkg.pr.new/@standardserver/peer@50

@standardserver/shared

npm i https://pkg.pr.new/@standardserver/shared@50

commit: 266c7a9

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/queue-undefined-sentinel-shift-eda977 (266c7a9) with main (db2dd09)

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dinwwwh
dinwwwh merged commit d32b063 into main Aug 3, 2026
10 checks passed
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.

1 participant