fix: handle 304 responses from edge functions#364
Merged
Conversation
5954f1b to
9ca4d6f
Compare
pieh
commented
Jul 18, 2025
Comment on lines
+55
to
+58
| cancel() { | ||
| streamController = null | ||
| worker.terminate() | ||
| }, |
Contributor
Author
There was a problem hiding this comment.
this part doesn't have test associated with it (at least right now)
the errors in handling messages from worker are just logged in deno process (global uncaught?), but they are not getting back to node land. In general the error message that this tries to address:
error: Uncaught TypeError: The stream controller cannot close or enqueue
streamController?.close()
^
at ReadableStreamDefaultController.close (ext:deno_web/06_streams.js:6054:13)
at Worker.worker.onmessage (file:///Users/misiek/dev/netlify-primitives/packages/edge-functions/dist-dev/deno/invoke.mjs:71:29)
at Worker.wrappedHandler (ext:deno_web/02_event.js:1400:12)
at innerInvokeEventListeners (ext:deno_web/02_event.js:757:7)
at invokeEventListeners (ext:deno_web/02_event.js:804:5)
at dispatch (ext:deno_web/02_event.js:661:9)
at Worker.dispatchEvent (ext:deno_web/02_event.js:1041:12)
at Worker.#pollMessages (ext:runtime/11_workers.js:253:12)
at eventLoopTick (ext:core/01_core.js:178:7)
doesn't really break behavior for users - the stream was already cancelled anyway (that's difficulty with testing this at least using existing test setups), but other than leaving errors like that for users to see in terminal - it might leave worker around as we only terminate worker after trying to close the controller:
primitives/packages/edge-functions/dev/deno/invoke.mjs
Lines 79 to 80 in 1a79a40
eduardoboucas
approved these changes
Jul 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref: withastro/astro#14087
Example added test failure without the fix from first commit: https://github.com/netlify/primitives/actions/runs/16374870164/job/46272177935?pr=364#step:11:391