Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Support node 20 #225

Open
lachrist opened this issue May 18, 2023 · 1 comment
Open

Support node 20 #225

lachrist opened this issue May 18, 2023 · 1 comment
Assignees

Comments

@lachrist
Copy link
Contributor

Since node 20, custom loaders are executed separately from the rest of the application. The problem is that we use that loader to preload the entire agent. So every hooks placed by the agent has no effect on the observed application. Another minor implication is that process.argv inside the loader no longer contains the main path, it only contains the node executable.

To solve this issue we have to adopt the same architecture as for the jest recorder where the transformer is isolated. To preload the agent we have 2 strategies:

  • Use --import which supports esm modules but I'm not sure how backward compatible this is.
  • Use --require which is older but it requires to bundle the agent as a commonjs module which is not currently the case.
@lachrist
Copy link
Contributor Author

lachrist commented Jun 5, 2023

Hooks are run in a separate thread, isolated from the main. That means it is a different realm. The hooks thread may be terminated by the main thread at any time, so do not depend on asynchronous operations (like console.log) to complete.

https://nodejs.org/dist/latest-v20.x/docs/api/esm.html#hooks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant