fix: prevent JSON parse error when loading data - #11025
Conversation
🦋 Changeset detectedLatest commit: a1dace1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Why is the response to the non-existent file returned as HTML and not as json? Would it be possible to solve this at the prerendering stage instead by creating a |
My guess is it's because the route doesn't exist in the server manifest (due to it being prerendered). So a request to
Right now we always fetch the kit/packages/kit/src/runtime/client/client.js Lines 1847 to 1858 in 87a18b7
Yes, this is another good alternative solution. Another alternative, is to always return JSON when |
|
updated to fallback to native navigation when receiving a HTML response instead of JSON when loading |
| } | ||
| } | ||
| } | ||
| handle_stream(); |
There was a problem hiding this comment.
What's this change about btw?
There was a problem hiding this comment.
ah I was trying to resolve to the TODO about the eslint error https://eslint.org/docs/latest/rules/no-async-promise-executor I can revert it though
There was a problem hiding this comment.
I don't think that lint rule applies here, so we can revert it
…ries to warn again
fixes #8751
This PR handles the edge case where loading the data of a non-existent prerendered dynamic route returns a 404 HTML page instead of JSON data. No test because our /basics test app has a root server layout load function, which causes it to do a native navigation instead, returning a 404 SSR response. The error only occurs when there is no root server layout load.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.