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

Give better error when receiving non-JSON response #1404

Merged
merged 5 commits into from
Dec 18, 2024

Conversation

Mtn-View
Copy link
Contributor

@Mtn-View Mtn-View commented Dec 17, 2024

Fixes # N/A : https://discord.com/channels/1024421016405016718/1301635915663278131

To help everyone out, please make sure your PR does the following:

  • Update the first line to point to the ticket that this PR fixes
  • Add a message that clearly describes the fix
  • If applicable, add a test that would fail without this fix
  • Make sure the unit and integration tests pass locally with pnpm run tests and cd integration && pnpm run tests
  • Includes a changeset if your fix affects the user with pnpm changeset

Without this, if the server returns a non-JSON error response such as an NGINX error page, defaultFetch will still attempt to parse the response as JSON, which will throw a syntax error. Instead, this PR changes it to throw the semantic HTTP error which is easier to understand than a SyntaxError from parsing HTML as JSON.

Without this, if the server returns an NGINX error page, `defaultFetch` will still attempt to parse the response as JSON, which will throw a syntax error, which is harder to understand than something like `502: Bad Gateway`
Copy link

changeset-bot bot commented Dec 17, 2024

🦋 Changeset detected

Latest commit: 398f4f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
houdini Patch
houdini-adapter-auto Patch
houdini-adapter-cloudflare Patch
houdini-adapter-node Patch
houdini-adapter-static Patch
houdini-react Patch
houdini-svelte Patch
houdini-plugin-svelte-global-stores Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for houdini-docs-next canceled.

Name Link
🔨 Latest commit 398f4f2
🔍 Latest deploy log https://app.netlify.com/sites/houdini-docs-next/deploys/6761b13a8bd67900085fc27c

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for houdinigraphql canceled.

Name Link
🔨 Latest commit 398f4f2
🔍 Latest deploy log https://app.netlify.com/sites/houdinigraphql/deploys/6761b13ae46b680008a4ef3f

Copy link
Collaborator

@SeppahBaws SeppahBaws left a comment

Choose a reason for hiding this comment

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

Maybe it could be useful if the error also contained something like "failed to fetch: server returned invalid response" or so, to be a bit more clear as to what went wrong.

@Mtn-View
Copy link
Contributor Author

Okay, the error message has been updated.

@Mtn-View Mtn-View requested a review from SeppahBaws December 17, 2024 20:48
Copy link
Collaborator

@SeppahBaws SeppahBaws left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for adding this in!

@SeppahBaws SeppahBaws merged commit d6375b6 into HoudiniGraphql:main Dec 18, 2024
15 checks passed
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
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