adapter-static can't build initial project
See original GitHub issueDescribe the bug
Current version of adapter-static broken from 1.0.0-next.24 version After that update adapter-static failing to build Kit template. Current Skeleton App not compatible with svelte kit, or svelte kit is not compatible with static adapter.
Reproduction
Create new kit project (npm init svelte@next my-app) install @sveltejs/adapter-static@next Add it to svelte.config.js as adapter instead of adapter-auto. Try to build app.
Logs
Run npm run preview to preview your production build locally.
> Using @sveltejs/adapter-static
> body used already for:
at consumeBody (file:///C:/proj/staticAdapterBroken/node_modules/@sveltejs/kit/dist/install-fetch.js:
4912:9)
at Response.text (file:///C:/proj/staticAdapterBroken/node_modules/@sveltejs/kit/dist/install-fetch.j
s:4877:24)
at visit (file:///C:/proj/staticAdapterBroken/node_modules/@sveltejs/kit/dist/chunks/index5.js:483:39
)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
System Info
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
Memory: 13.38 GB / 31.88 GB
Binaries:
Node: 16.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.22.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.62)
Internet Explorer: 11.0.19041.1202
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.14
@sveltejs/adapter-static: ^1.0.0-next.26 => 1.0.0-next.26
@sveltejs/kit: next => 1.0.0-next.236
svelte: ^3.44.0 => 3.46.2
Severity
blocking all usage of SvelteKit
Additional Information
Actually I was trying to fix https://github.com/MailCheck-co/mailcheck.site/commit/abecae86f209ffc9abdae02d59611bb406235472, but during debug I disabled everything in project with no luck. Then I tried to create new project, and found that new projects are broken from start.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:17
- Comments:24 (5 by maintainers)
Top Results From Across the Web
Can't figure out how to use adapter-static in sveltekit - Reddit
I'm building a small frontend and am using sveltekit because it provides routing out of the box, but I'm having some trouble building...
Read more >SvelteKit on Netlify
To deploy a SvelteKit project on Netlify, use SvelteKit's Netlify adapter. This adapter deploys SvelteKit endpoints as Netlify Functions.
Read more >How to deploy an Astro site
Learn how to deploy an Astro project as a static, server-rendered, or edge-rendered site, try out some Netlify templates, and learn how to ......
Read more >sveltekit static adapter does not work on cloudflare pages
config.json ). Ensure that your .gitignore does not include the /build directory unless you want to use the Build command config then ...
Read more >Announcing SvelteKit 1.0
As of today, it's the recommended way to build Svelte apps of all ... you can use adapter-static — which turns SvelteKit into...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t fully understand how this is happening but I’ve narrowed it down. Basically,
node-fetch
doesn’t allow you to “consume” a response body more than once, i.e. you can’t callawait response.text()
more than once on the same response. That’s the immediate cause of the error.It happens in prerender’s
visit()
method. It callsapp.render()
which populates thedependencies
Map. The values of the map are Response objects. The body of these Response objects is consumed inload_node
here. Then, whenvisit()
iterates through the dependencies, it tries to consume the body again here. This fails for the reason described above.I’m not sure what the right fix would be here because I don’t understand the code well enough but I’m pretty sure this is the source of the error.
Facing the same problem with my own SvelteKit project, I also noticed that the default project doesn’t build. It was a bit tricky to see which release introduced this bug, but from my experiments it looks like builds start to fail from
@sveltejs/kit@^1.0.0-next.234
(although that fails with a different errorrequest in handle has been replaced with event
).I arrived at this conclusion by doing the following (which might not be the correct approach…)
npm init svelte@2.0.0-next.94 my-app
,cd my-app
, andnpm install
npm i -D @sveltejs/adapter-static@next
and set adapter-static in svelte.config.js (fails)npm install -D @sveltejs/kit@1.0.0-next.233
(builds)npm install -D @sveltejs/kit@1.0.0-next.234
(fails)