Skip to content

Conversation

@wpessers
Copy link
Contributor

Since RITM upgrade to v8.0.0 in @opentelemetry/instrumentation, a fallback on the resolve module was removed: nodejs/require-in-the-middle@67076ff#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L73

This fallback seems not to have been intended to support bundled code, but as a side effect it did. When bundling code with webpack, webpack provides its own loader instead of the node.js native require.resolve. When using require.resolve inside code bundled with webpack, it can only resolve modules that are in the bundle. The above link to the old code highlights the check for require.resolve && require.resolve.paths both being truthy. This check would fail since the require.resolve.paths is undefined since it isn't needed in webpack's "stubbed" require.resolve, leading to the resolve module being used instead.

So since this change was introduced, that is actually breaking instrumentation that needs to hook non-core modules through RITM.

This change externalizes the RITM dependency so it can make use of the actual node.js require.resolve in the node.js runtime instead of the webpack loader.

@wpessers wpessers requested a review from a team as a code owner November 27, 2025 13:12
@wpessers wpessers added bug Something isn't working javascript Pull requests that update Javascript code labels Nov 27, 2025
@serkan-ozal
Copy link
Contributor

This is the best and safest fix we can do as quickly as possible, so merging it. Thanks for your efforts @wpessers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants