-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Bad error message for assert.ok
in ESM
#50593
Comments
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. |
Both cases, the error iso originating from the assert. Also, inside the asserts, we are generating the message using an attempt to open the file
|
For ESM, Line 299 in adf332b
|
This PR addresses issue nodejs#50593, which was caused by the design in the ESM loader. The ESM loader was modifying the file path and replacing the 'file' property with the file proto in the stack trace. This, in turn, led to unhandled exceptions when the assert module attempted to open the file to display erroneous code. The changes in this PR resolve this issue by handling the file path correctly, ensuring that the remaining message formatting code can execute as expected.
This PR addresses issue nodejs#50593, which was caused by the design in the ESM loader. The ESM loader was modifying the file path and replacing the 'file' property with the file proto in the stack trace. This, in turn, led to unhandled exceptions when the assert module attempted to open the file to display erroneous code. The changes in this PR resolve this issue by handling the file path correctly, ensuring that the remaining message formatting code can execute as expected.
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.ok
call.Additional information
No response
The text was updated successfully, but these errors were encountered: