Skip to content

Yarn Switch terminates before the child process does #236

@merceyz

Description

@merceyz

With a script like

process.on("SIGINT", () => {
	console.log("SIGINT received");
});
process.on("SIGTERM", () => {
	console.log("SIGTERM received");
});

setInterval(() => {
	console.log("tick");
}, 1000);

running node index.js and sending it a SIGINT it will continue running.
When using Yarn switch running yarn node index.js the switch process terminates and the underlying process keeps running.

Dockerfile reproduction:

FROM node:24.13.0
RUN curl -s https://repo.yarnpkg.com/install | bash
ENV PATH="/root/.yarn/switch/bin:$PATH"
RUN yarn switch --version
RUN cat <<EOF > index.js
process.on("SIGINT", () => {
	console.log("SIGINT received");
});
process.on("SIGTERM", () => {
	console.log("SIGTERM received");
});

setInterval(() => {
	console.log("tick");
}, 1000);
EOF
CMD ["yarn", "node", "index.js"]

Building and running that container it terminates as soon as the signal arrives instead of continuing to run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions