Skip to content

fix(peer): finalize hibernation iterators instead of throwing on cleanup - #49

Merged
dinwwwh merged 1 commit into
mainfrom
claude/hibernation-async-iterator-cleanup-8374c8
Aug 2, 2026
Merged

fix(peer): finalize hibernation iterators instead of throwing on cleanup#49
dinwwwh merged 1 commit into
mainfrom
claude/hibernation-async-iterator-cleanup-8374c8

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 2, 2026

Copy link
Copy Markdown
Member

Cleaning up a HibernationAsyncIteratorClass (via return, throw, or async dispose) no longer throws, and the server now finalizes the iterator right after the hibernation callback runs, so it always ends up properly closed.

Fixes

  • HibernationAsyncIteratorClass cleanup was throwing "Cannot use hibernating iterator directly" on cancellation, so any generic code path that closed the iterator would blow up. Only direct iteration via next() still throws.
  • ServerPeer now calls return() on the iterator in a finally after invoking the hibernation callback, so the iterator is finalized even when the callback rejects; the rejection still propagates and cancels the request as before.

Testing

  • Server tests assert the iterator reports { done: true } after handling, for both successful and rejecting callbacks.
  • All peer package tests pass and typecheck is clean.

HibernationAsyncIteratorClass no longer throws when its cleanup runs
(return/throw/asyncDispose), and ServerPeer now finalizes the iterator
right after invoking the hibernation callback, even when the callback
rejects.
@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026

Copy link
Copy Markdown
@standardserver/aws-lambda

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

@standardserver/bun

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

@standardserver/core

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

@standardserver/deno

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

@standardserver/fastify

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

@standardserver/fetch

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

@standardserver/node

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

@standardserver/peer

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

@standardserver/shared

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

commit: 471ee2a

@codecov

codecov Bot commented Aug 2, 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 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/hibernation-async-iterator-cleanup-8374c8 (471ee2a) with main (fada571)

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 db2dd09 into main Aug 2, 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