Skip to content

fix(cache): settle Cache.add/addAll for responses with a body - #5658

Open
edenbuilds wants to merge 1 commit into
nodejs:mainfrom
edenbuilds:fix/cache-add-body-hang
Open

fix(cache): settle Cache.add/addAll for responses with a body#5658
edenbuilds wants to merge 1 commit into
nodejs:mainfrom
edenbuilds:fix/cache-add-body-hang

Conversation

@edenbuilds

Copy link
Copy Markdown

Summary

  • Cache.add / Cache.addAll hung forever when the response had a body (204/no-body settled fine).
  • Root cause: fetchFinale attaches stream.finished() for end-of-body, but undici body streams are pull-driven — with no consumer, the stream never finishes and processResponseEndOfBody never resolves the waiters (issue Cache.add() and Cache.addAll() never settle for a response with a body #5615).
  • Fix mirrors Cache.put: clone the response, fully read the original stream (unlocks end-of-body), set body.source on the clone for storage.

Test plan

Made with Cursor

Pull-driven body streams were never consumed, so processResponseEndOfBody
never ran and Cache.add hung forever. Clone, fully read (as Cache.put does),
and store body.source. Fixes nodejs#5615.

Co-authored-by: Cursor <cursoragent@cursor.com>
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