Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move error enrichment back; fix condition
  • Loading branch information
GeoffreyBooth committed Mar 23, 2024
commit b66b39e100c40c00bd31a94b6c3d976514de7e99
2 changes: 0 additions & 2 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,6 @@ function wrapSafe(filename, content, cjsModuleInstance, codeCache) {
// For the main entry point, cache the source to potentially retry as ESM.
module.exports.entryPointSource = content;
}
const { enrichCJSError } = require('internal/modules/esm/translators');
enrichCJSError(err, content, filename);
}
throw err;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/modules/run_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ function executeUserEntryPoint(main = process.argv[1]) {
}

if (!retryAsESM) {
if (Module === process.mainModule) {
const { enrichCJSError } = require('internal/modules/esm/translators');
enrichCJSError(error, source, resolvedMain);
}
return true; // Rethrow original exception.
}
});
Expand Down