-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
ERR_INVALID_RETURN_PROPERTY_VALUE with load hook and commonjs #50435
Comments
Before 20.6.0, the /cc @nodejs/loaders |
This statement does not seem to match the documentation for 20.x. In the column for "Acceptable types for
There's also extended discussion below about the behavior:
If nothing else, perhaps it should mention in there that there's no mixing-and-matching, a |
As a stopgap, yes, the docs should at least document the current state of affairs until we can improve it. |
I am running into the same issue for the same reasons: Playwright config and upgrading to node v20.9 Per this thread, I am unclear what is the suggested stopgap:
=> I fail to see how updating the doc is a stopgap for the issue unless I don't understand something. I am not clear as well if this is a bug or not that needs to be addressed in Playwright, or if by any chance I can modify something in my code.. Right now, downgrading node seems to be my only option... |
Nevermind: I turned the common config into a hybrid ESM / CommonJs lib and now the problem above is resolved for the ESM app and the common config is still working for all other CommonJs apps... |
The issue happens if the load hook returns a non-null/undefined Playwright's current loader does this when the first commonjs file is not inside |
Thanks for the minimal repro, I was wondering why Yarn PnP chained to Datadog IITM (wrapped by OTel-JS) was not working correctly post Node 20.6. |
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
When using the Modules Customization Hooks API to load CommonJS modules, we want to support the returned value of `defaultLoad` which must be nullish to preserve backward compatibility. This can be achieved by fetching the source from the translator. PR-URL: #50825 Fixes: #50435 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
Confirmed fixed by the backport. 20.11 works flawlessly now with yarn pnp and with datadog iitm |
Version
v20.9.0
Platform
Linux abulia 6.5.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1 (2023-10-07) x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Create the following files:
register-hooks.mjs
hooks.mjs
foo.cjs
bar.cjs
Run
node --import ./register-hooks.mjs foo.cjs
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
Script runs, printing "hello, world".
Because that's what this very simple code does. 🤷
What do you see instead?
Additional information
This seems to have been introduced in v20.6.0, as v20.5.1 is not affected. Likely it's part of the enhancements to the load hook added in that version.
What seems to be happening is that once one commonjs file returns a non-null
source
, any sub-requires of that file will fail if null is returned forsource
despite that being the default behavior for the passed-innextLoad
function.I ran into this while trying to figure out why playwright started giving me this error when I tried to update from Node 18 to Node 20. The loader can be found here, and the bug was being triggered by a
mjs
config file that imports acjs
file that requires something out ofnode_modules
. They've also got some other stuff going on in there, if I hack that loader to always fill insource
then it winds up hanging eventually at this line (it seems that sends a message on the MessagePort that the other side never reacts to?).Considering the comment I see in the doc that "This behavior for nullish source is temporary — in the future, nullish source will not be supported", I suppose you might decide this isn't a bug, saying that any loader that "opts in" to this behavior should carry it all the way through.
The text was updated successfully, but these errors were encountered: