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

  1. Clone the repository to your local system
  2. Navigate into the repository directory
  3. Install all dependencies using npm install
  4. Build the production server using npm run build
  5. Start the production server using node build
  6. 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

Most upvoted comments

comment build/index.js compress will make it work sed -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 the Accept-Encoding: gzip header on the request

this issue is related to compression package

but curl works! lol

Pinning next.77 works for now while the compression PR is being reviewed.

"@sveltejs/adapter-node": "1.0.0-next.77",

Does this also effect adapter-auto? Having some issues right after upgrading. Downgrading doesn’t help. I’m thinking about blaming the new vite.config.js setup

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 version 1.0.0-next.81