-
Notifications
You must be signed in to change notification settings - Fork 395
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
Update esm-loader to work with Node 20 #1720
Comments
I'm capturing my findings to date. We wrote the esm loader to really do 3 things:
As described in the description above nodejs/node#44710 moved loaders to their own threads. This caused a few issues:
I was able to load the agent in the main thread by implementing the
With that being said, I moved on to figure out how to get the load hook to work to proxy ESM exports. It is worth noting the work mentioned above is going away as We will still need to figure out how to properly get the ESM exports so they can be instrumented. import-in-the-middle went the parse the ESM source into AST and get the exports that way. There was a long discussion about all of this and want to capture it in here. However it got closed because IITM just extract exports via AST parsing. We will have to wait if there is a native solution to this but sounds like there probably won't be. With all that being said I propose we move this to the backlog and wait for Node. 20 to release a stable loader API to tackle. The reason I propose this is because we only have 1 custom using custom ESM instrumentation. We can get CJS working in ESM by implementing a more permissive matching of packages to our instrumentation. This is being done in #1646. We can then release support for Node 20 and drop 14 and make sure we include the known issues with ESM custom instrumentation. |
Moving this back until the loader API has the new stable hook points |
Description
During our investigation of Node.js 20 it was discovered the runtime has changed how loaders work. They now run in their own threads: nodejs/node#44710. They provided a temporary hook
globalPreload
that shares context with the main runtime.Acceptance Criteria
What tasks need to be accomplished to achieve the goal?
As a New Relic Node.js user I want the ability to run the node agent with ESM on Node.js 20 so that I can see my telemetry data in NR1.
Additional context
This will take some time to solve but I think we if we load the agent, shimmer, etc in the globalPreload hook we should be good.
The text was updated successfully, but these errors were encountered: