question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch crashes in SSR

See original GitHub issue

Describe the bug

I have /, a page that automatically fetches the endpoint /api/categories/2. This completely breaks SSR fetch. Error included in logs

Reproduction

  1. Use @sveltejs/kit@next (1.0.0-next.131 and 1.0.0-next.133 tested)
  2. Fetch an endpoint from a page from SSR
  3. ‘Enjoy’?

Logs

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:363:5)
    at onParseError (node:internal/url:536:9)
    at new URL (node:internal/url:612:5)
    at new Request (file:///mnt/dev/hamza/node_modules/@sveltejs/kit/dist/install-fetch.js:1239:16)
    at file:///mnt/dev/hamza/node_modules/@sveltejs/kit/dist/install-fetch.js:1448:19
    at new Promise (<anonymous>)
    at fetch (file:///mnt/dev/hamza/node_modules/@sveltejs/kit/dist/install-fetch.js:1446:9)

System Info

System:
    OS: Linux 5.10 Arch Linux
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 6.33 GB / 15.63 GB
    Container: Yes
    Shell: 3.2.2 - /bin/fish
  Binaries:
    Node: 16.3.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 7.15.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 91.1.25.68
    Firefox: 88.0.1
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.133 
    svelte: ^3.34.0 => 3.38.3

Severity

can work around it, it’ll just be ugly

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
babeardcommented, Jul 21, 2021

I’ve been bitten in the past by not using kit’s built in fetch within the load function. Hopefully this solves your problem as well.

-   export async function load() {
+   export async function load({ fetch }) {
0reactions
manencommented, Jul 22, 2021

Okay 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

DNS issues kill SvelteKit SSR process with fetch() #4775
If a fetch() DNS resolution fails the SvelteKit server-side rendering process of node-adapter crashes and dies. It is unusual for a failed fetch...
Read more >
React app with Server-side rendering crashes with load
I'm using react-boilerplate (with react-router, sagas, express.js) for my React app and on top of it I've added SSR logic so that once...
Read more >
SvelteKit Crash Course Tutorial #8 - Loading Data & SSR
Get access to this course on Net Ninja Pro:https://netninja.dev/p/sveltekit-tutorial Get access to more premium courses on Net Ninja ...
Read more >
NextJS and React-Query - Server Side fetching of data - SSR
In this quick tutorial you'll learn how to fetch data on the server with React-Query and NextJS. This is great as the data...
Read more >
What's new in Next.js 13, and what do they really do?
based on the data is no longer possible. 5. SSR/SSG/ISR with the extended fetch API. Server Side Rendering (SSR), Static Site Generation (SSG),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found