Skip to content
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

Incorrect exitCode when process fails due to circular dependency of dynamic import #53551

Open
saurabhdaware opened this issue Jun 22, 2024 · 0 comments
Labels
loaders Issues and PRs related to ES module loaders process Issues and PRs related to the process subsystem.

Comments

@saurabhdaware
Copy link
Contributor

Version

20.15.0

Platform

Darwin Saurabhs-MacBook-Air.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103 arm64

Subsystem

No response

What steps will reproduce the bug?

CodeSandbox Reproduction

// a.js
export const utilityFunction = () => {
  return 'woah nice utility';
}

process.on('exit', (exitCode) => {
  // This prints 0 but the correct code should be 13
  console.log('exitCode', exitCode);
});

try {
  const defaultImpB = (await import('./b.js')).default;
  console.log('try');
  console.log({defaultImpB});
} catch (e) {
  console.log('catch')
} finally {
  console.log('finally');
}

// b.js
import { utilityFunction } from './a.js';

const test = () => {
  return 'test';
}

export default test;
# This prints exit code 0
node a.js

# This prints exit code 13
echo $?

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

exitCode should return 13 code

What do you see instead?

exitCode returns 0

Additional information

There is #44601 issue which talks about early exit. But my main concern was the exitCode being 0 since there is no other way to debug this issue when process exits with success code

@RedYetiDev RedYetiDev added process Issues and PRs related to the process subsystem. loaders Issues and PRs related to ES module loaders labels Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loaders Issues and PRs related to ES module loaders process Issues and PRs related to the process subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants