Skip to content

Conversation

@ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Aug 10, 2025

This fixes some tests currently failing in CI.


const cwdNotExisting = {cwd: 'does_not_exist', expectedCode: 'ENOENT', expectedMessage: 'The "cwd" option is invalid'};
const cwdTooLong = {cwd: '.'.repeat(1e5), expectedCode: 'ENAMETOOLONG', expectedMessage: 'The "cwd" option is invalid'};
const cwdTooLong = {cwd: '.'.repeat(1e5), expectedCode: isWindows && majorNodeVersion >= 20 ? 'ENOENT' : 'ENAMETOOLONG', expectedMessage: 'The "cwd" option is invalid'};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When calling child_process.spawn() with a cwd that has a long name, the error.code is ENAMETOOLONG on Unix. It used to be that on Windows too, but since Node 24.2.0 it's ENOENT. I could not find the commit in the Node changelog that changed that behavior, but it's nothing that's impacted Execa's code, so it's ok.

t.is(exitCode, 1);
t.false(isTerminated);
t.true(message.includes('Error: getOneMessage() cannot be used: the parent process has already exited or disconnected'));
t.true(message.includes('Error: getOneMessage()'));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those tests rely on a race condition between the time it takes to spawn a process vs to send an IPC message. Those fixes help prevent that.

@sindresorhus sindresorhus merged commit 5587ae1 into main Aug 10, 2025
14 checks passed
@sindresorhus sindresorhus deleted the test-ci-error branch August 10, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants