Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decompress body from edge functions errors #6010

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

eduardoboucas
Copy link
Member

Summary

Right now, if an edge function throws an unhandled exception, the CLI will crash with a cryptic error message:

SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at formatEdgeFunctionError (file:///Users/eduardoboucas/Sites/netlify/cli/src/utils/proxy.mjs:65:12)
    at IncomingMessage.onEnd (file:///Users/eduardoboucas/Sites/netlify/cli/src/utils/proxy.mjs:548:31)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

This is because the edge function is sending a compressed response which the CLI needs to decompress. We do have some logic for checking whether the body needs to be decompressed, which we've added in #5837, but we're reading the accept-encoding header from the incoming request, when we should be reading it from the response we get from the Deno server.

@github-actions
Copy link

📊 Benchmark results

Comparing with 3dcae88

  • Dependency count: 1,365 (no change)
  • Package size: 366 MB ⬇️ 0.00% decrease vs. 3dcae88

@eduardoboucas eduardoboucas changed the title fix: decompress body from edge functions before parsing error fix: decompress body from edge functions errors Sep 18, 2023
@eduardoboucas eduardoboucas marked this pull request as ready for review September 18, 2023 23:16
@eduardoboucas eduardoboucas requested a review from a team as a code owner September 18, 2023 23:16
Copy link
Collaborator

@lukasholzer lukasholzer left a comment

Choose a reason for hiding this comment

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

LGTM!

@eduardoboucas eduardoboucas merged commit e6f5113 into main Sep 19, 2023
63 checks passed
@eduardoboucas eduardoboucas deleted the fix/edge-functions-errors branch September 19, 2023 08:40
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