fix(adapter-node): skip socket cleanup for cluster workers#16241
Open
tsushanth wants to merge 1 commit into
Open
fix(adapter-node): skip socket cleanup for cluster workers#16241tsushanth wants to merge 1 commit into
tsushanth wants to merge 1 commit into
Conversation
The stale-socket cleanup added in sveltejs#15449 runs on every process start, but in Node cluster / PM2 cluster mode all worker processes share the primary's socket handle. A live unix socket also reports size = 0, so each worker deletes the socket file the primary just created. After the deletion the reverse proxy can no longer connect — the server appears healthy (workers share the in-kernel listening state) but the socket path is gone from disk. Fix: skip the rm() call when process is a cluster worker. Workers never bind the socket themselves, so they must never clean it up.
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/9fd278c9ccade1944441c961fcc6f855891b15f8Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16230.
Root cause
The stale-socket cleanup added in #15449 (released in adapter-node 5.5.7) unconditionally runs on every process startup:
The
size === 0heuristic is meant to detect a stale socket left over from an unclean shutdown, but a live unix domain socket also reportssize = 0. In Node cluster / PM2 cluster mode:bind()of its own), runs the same startup code, findssize === 0, and deletes the live socket file.proxy_pass unix:…) can no longer connect. No error, no restart, silent regression.Fix
Import
node:clusterand skip therm()call when the current process is a cluster worker. Workers inherit the socket handle from the primary and must never manage the socket file. The primary (or any single-process deployment) retains the existing cleanup behaviour unchanged.cluster.isWorkerisfalsein non-cluster processes, so this change is a no-op for single-process deployments.