@sveltejs/adapter-node
Advanced tools
Comparing version 5.0.2 to 5.1.0
@@ -273,9 +273,15 @@ import { handler } from 'HANDLER'; | ||
function shutdown() { | ||
/** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */ | ||
function graceful_shutdown(reason) { | ||
if (shutdown_timeout_id) return; | ||
// If a connection was opened with a keep-alive header close() will wait for the connection to | ||
// time out rather than close it even if it is not handling any requests, so call this first | ||
// @ts-expect-error this was added in 18.2.0 but is not reflected in the types | ||
server.server.closeIdleConnections(); | ||
server.server.close(() => { | ||
server.server.close((error) => { | ||
// occurs if the server is already closed | ||
if (error) return; | ||
if (shutdown_timeout_id) { | ||
@@ -287,2 +293,5 @@ shutdown_timeout_id = clearTimeout(shutdown_timeout_id); | ||
} | ||
// @ts-expect-error custom events cannot be typed | ||
process.emit('sveltekit:shutdown', reason); | ||
}); | ||
@@ -310,4 +319,4 @@ | ||
if (requests === 0 && shutdown_timeout_id) { | ||
// when all requests are done, close the connections, so the app shuts down without delay | ||
if (shutdown_timeout_id) { | ||
// close connections as soon as they become idle, so they don't accept new requests | ||
// @ts-expect-error this was added in 18.2.0 but is not reflected in the types | ||
@@ -317,3 +326,3 @@ server.server.closeIdleConnections(); | ||
if (requests === 0 && socket_activation && idle_timeout) { | ||
idle_timeout_id = setTimeout(shutdown, idle_timeout * 1000); | ||
idle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000); | ||
} | ||
@@ -324,5 +333,5 @@ }); | ||
process.on('SIGTERM', shutdown); | ||
process.on('SIGINT', shutdown); | ||
process.on('SIGTERM', graceful_shutdown); | ||
process.on('SIGINT', graceful_shutdown); | ||
export { host, path, port, server }; |
{ | ||
"name": "@sveltejs/adapter-node", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"description": "Adapter for SvelteKit apps that generates a standalone Node server", | ||
@@ -38,3 +38,2 @@ "keywords": [ | ||
"@types/node": "^18.19.3", | ||
"c8": "^9.0.0", | ||
"polka": "1.0.0-next.25", | ||
@@ -58,3 +57,3 @@ "sirv": "^2.0.4", | ||
"build": "node -e \"fs.rmSync('files', { force: true, recursive: true })\" && rollup -c", | ||
"test": "echo \"tests temporarily disabled\" # c8 vitest run", | ||
"test": "echo \"tests temporarily disabled\" # vitest run", | ||
"check": "tsc", | ||
@@ -61,0 +60,0 @@ "lint": "prettier --check .", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53582
8
1636