-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@sveltejs/adapter-node generates corrupted server #5431
Comments
Updated information to reflect this only occures after 1.0.0-next.79 |
Hmm. It looks like |
Confirmed - got the same problem! |
Ah, the Demo project works because it prerenders the index page while the Skeleton project does not |
It works if I pin |
Using |
@DrDanRyan that's because |
I pinned TypeScript to 4.7.2 in |
Well and plus the |
but curl works! lol |
Fix here: 810c52b I accidentally screwed up and pushed it to |
Thanks for the issue, I was trying to figure out what went wrong. Facing the same issue, our production deployment is failing |
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 issue is related to compression package |
This happend due to the order of my vite plugins in my |
Pinning next.77 works for now while the compression PR is being reviewed.
|
@SeaniaTwix Curl works for mine, too. @coryvirok Pinning to earlier versions hasn't worked for me. I've tried 78 and 77. The page remains blank.
|
@xpat @SeaniaTwix the reason it works on |
@benmccann can we have an environment var to toggle the compression middleware? this could work as workaround for this issue as I understand, those users with a proxy in front of the node process, like nginx/apache, could run the compression in that context // packages/adapter-node/src/env.js
/* global ENV_PREFIX */
const expected = new Set([
'SOCKET_PATH',
'HOST',
'PORT',
'ORIGIN',
'XFF_DEPTH',
'ADDRESS_HEADER',
'PROTOCOL_HEADER',
'HOST_HEADER',
'COMPRESSION_ENABLED'
]);
if (ENV_PREFIX) {
for (const name in process.env) {
if (name.startsWith(ENV_PREFIX)) {
const unprefixed = name.slice(ENV_PREFIX.length);
if (!expected.has(unprefixed)) {
throw new Error(
`You should change envPrefix (${ENV_PREFIX}) to avoid conflicts with existing environment variables — unexpectedly saw ${name}`
);
}
}
}
}
/**
* @param {string} name
* @param {any} fallback
*/
export function env(name, fallback) {
const prefixed = ENV_PREFIX + name;
return prefixed in process.env ? process.env[prefixed] : fallback;
} // packages/adapter-node/src/index.js
import { handler } from './handler.js';
import { env } from './env.js';
import compression from 'compression';
import polka from 'polka';
export const path = env('SOCKET_PATH', false);
export const host = env('HOST', '0.0.0.0');
export const port = env('PORT', !path && '3000');
export const compression_enabled = env('COMPRESSION_ENABLED', 'true') === 'true';
const compression_middleware = compression_enabled ? compression({ threshold: 0 }) : undefined;
const middlewares = [compression_middleware, handler].filter(Boolean);
// https://github.com/lukeed/polka/issues/173
// @ts-ignore - nothing we can do about so just ignore it
const server = polka().use(...middlewares);
server.listen({ path, host, port }, () => {
console.log(`Listening on ${path ? path : host + ':' + port}`);
});
export { server }; |
Which sveltekit version are you using meanwhile? @coryvirok |
Nvm it doesn't matter... I forgot to |
Hi there. Downgrading to node adapter v77 not working for me. Tried with sveltekit v370, v366 |
Delete package-lock.json and do npm ci then it should work |
Still no result. I'm using vite v3.0.0 |
comment |
@shynome That worked. Nice. |
will be fixed in the next version of |
FYI: Still hangs for me on anything above node-adapter 1.0.0-next-78 |
It wasn't released yet. Try |
Oh, ha - that would do it! I just saw a new version and connected the dots to make a whole different picture 😀 |
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 tosveltejs/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 thehandler
polka middleware insidebuild/index.js
to a custom handler like so:and run
node build
the server instantly responds withHello 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
npm install
npm run build
node build
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
System Info
Severity
EDIT:
blocking an upgrade (as this issue was introduced by .79 as I found out now)
Additional Information
No response
The text was updated successfully, but these errors were encountered: