Repository navigation
Bad error message for assert.ok in ESM #50593
Description
Activity
- addedassertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
on Nov 7, 2023 I think the variation you're seeing in error outputs between CJS and ESM is due to their different execution contexts—CJS is synchronous, while ESM is inherently asynchronous.
error code is same, so the message has to be.
Checking the implementation.
Reacted by user1083789041Both cases, the error iso originating from the assert.
In CJS, the error will reach directly to the file. But, for ESM, theesm_loaderwill catch and re-throw this exception usingtriggerUncaughtExceptioninternal bindings.Also, inside the asserts, we are generating the message using
getErrorMessagefunction. There we are prefixing the messageThe expression evaluated to a falsy value:for errors.an attempt to open the file
fd = openSync(filename, 'r', 0o666);is failing for ESM. So, the further message formatting being skipped.static void TriggerUncaughtException(const FunctionCallbackInfo<Value>& args) {Reacted by user1083789041For ESM,
call.getFileName()is returning fileName asfile://<path to file>instead of/<path to file>
Line 299 in adf332b
const filename = call.getFileName(); Fix raised
PR landed hence closing the issue. Thanks @nicolo-ribaudo for bringing this issue to notice.
Version
21.1.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
The CJS code throws this error:
I would expect something similar for ESM
What do you see instead?
ESM throws this error:
Without showing the
assert.okcall.Additional information
No response