Skip to content

fix: handle 304 responses from edge functions#364

Merged
pieh merged 4 commits intomainfrom
fix/edge-functions-304-responses
Jul 21, 2025
Merged

fix: handle 304 responses from edge functions#364
pieh merged 4 commits intomainfrom
fix/edge-functions-304-responses

Conversation

@pieh
Copy link
Contributor

@pieh pieh commented Jul 18, 2025

@pieh pieh force-pushed the fix/edge-functions-304-responses branch from 5954f1b to 9ca4d6f Compare July 18, 2025 15:54
Comment on lines +55 to +58
cancel() {
streamController = null
worker.terminate()
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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:

streamController?.close()
worker.terminate()

@pieh pieh changed the title test: add test for edge function returning 304 response fix: handle 304 responses from edge functions Jul 18, 2025
@pieh pieh marked this pull request as ready for review July 18, 2025 17:14
@pieh pieh requested a review from a team as a code owner July 18, 2025 17:14
@pieh pieh merged commit 08e2543 into main Jul 21, 2025
19 of 21 checks passed
@pieh pieh deleted the fix/edge-functions-304-responses branch July 21, 2025 07:01
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.

2 participants