kit: @sveltejs/adapter-node generates corrupted server
Describe the bug
⚠ Disclaimer
First of all I’m not a native english speaker so please forgive my sometimes bad english! ❤
Second of all I’m not entirely sure if this issue belongs to sveltejs/kit
or more to sveltejs/kit/adapter-node
but as they both are on the same repository I’m posting this issue here anyway.
🐞 The bug
EDIT: This issue was introduced in 1.0.0-next.79 as my other project with 1.0.0-next.78 works fine.
While testing some stuff out for further information on #5412 I discovered the inability to generate production servers using adapter-node
.
When building a production server using @sveltejs/adapter-node
the generated server takes forever to respond (running in clientTimeout after 300s). When I switch the handler
polka middleware inside build/index.js
to a custom handler like so:
const server = polka().use(
// https://github.com/lukeed/polka/issues/173
// @ts-ignore - nothing we can do about so just ignore it
compression$1.exports({ threshold: 0 }),
(req, res) => res.end('Hello world')
);
and run node build
the server instantly responds with Hello world
so the issue is somewhere in the sveltekit handler.
🌟A solution
I don’t know what exactly causes this problem so I can’t give any solution 😥.
But this needs to be fixed somehow as it makes production builds using adapter-node
impossible!
Reproduction
Manual reproduction
Repository: https://github.com/UnlimitedBytes/sveltekit-adapter-node-issue
- Clone the repository to your local system
- Navigate into the repository directory
- Install all dependencies using
npm install
- Build the production server using
npm run build
- Start the production server using
node build
- Open your webbrowser and navigate to
http://127.0.0.1:3000
FAST (automatic) reproduction
Execute the following commands
git clone https://github.com/UnlimitedBytes/sveltekit-adapter-node-issue
cd sveltekit-adapter-node-issue
npm install
npm run build
node build
Open your webbrowser and navigate to http://127.0.0.1:3000
Logs
Console:
> Listening on 0.0.0.0:3000
Browser:
Loading for ever
System Info
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 AMD Ryzen™ 7 5800X3D @ 4.50GHz
Memory: 6.05 GB / 32.00 GB
Binaries:
Node: 18.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.13.1 - ~\AppData\Roaming\npm\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.44)
Internet Explorer: 11.0.19041.1566
npmPackages:
@sveltejs/adapter-node: ^1.0.0-next.79 => 1.0.0-next.79
@sveltejs/kit: next => 1.0.0-next.366
svelte: ^3.44.0 => 3.49.0
vite: ^2.9.13 => 2.9.14
Severity
EDIT: blocking an upgrade (as this issue was introduced by .79 as I found out now)
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 25
- Comments: 30 (15 by maintainers)
Commits related to this issue
- Downgrade adapter-node See https://github.com/sveltejs/kit/issues/5431 — committed to jason0x43/spellingcee by jason0x43 2 years ago
- downgrade adapter-node due to https://github.com/sveltejs/kit/issues/5431 — committed to auslan-find-sign/find-sign-website by Bluebie 2 years ago
- pin old node-adapter until https://github.com/sveltejs/kit/issues/5431 is resolved — committed to tokenocean/raretoshi by asoltys 2 years ago
- pin old node-adapter until https://github.com/sveltejs/kit/issues/5431 is resolved — committed to coinos/coinos-marketing by asoltys 2 years ago
- pin old node-adapter until https://github.com/sveltejs/kit/issues/5431 is resolved — committed to tokenocean/raretoshi by asoltys 2 years ago
- pin old node-adapter until https://github.com/sveltejs/kit/issues/5431 is resolved — committed to tokenocean/mintalio by asoltys 2 years ago
comment
build/index.js
compress will make it worksed -i 's|compression$1.exports({ threshold: 0 })|//compression$1.exports({ threshold: 0 })|g' build/index.js
@xpat @SeaniaTwix the reason it works on
curl
is bc you are not sending theAccept-Encoding: gzip
header on the requestthis issue is related to compression package
but curl works! lol
Pinning next.77 works for now while the compression PR is being reviewed.
This happend due to the order of my vite plugins in my
vite.config.js
. Apparently SvelteKit needed to run AFTER everything else.Oh, ha - that would do it! I just saw a new version and connected the dots to make a whole different picture 😀
It wasn’t released yet. Try
@sveltejs/adapter-node
version1.0.0-next.81