-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add end2end test for compatibility with dd-trace
Fetch in node.js is powered by undici, node requires undici when fetch is called the first time: let fetchImpl; // https://fetch.spec.whatwg.org/#fetch-method ObjectDefineProperty(globalThis, 'fetch', { __proto__: null, configurable: true, enumerable: true, writable: true, value: function fetch(input, init = undefined) { // eslint-disable-line func-name-matching if (!fetchImpl) { // Implement lazy loading of undici module for fetch function const undiciModule = require('internal/deps/undici/undici'); fetchImpl = undiciModule.fetch; } return fetchImpl(input, init); }, }); Only then will setGlobalDispatcher be available (albeit via a symbol hack) We need to wait until setGlobalDispatcher is properly exposed: nodejs/node#43187 We be able to call setGlobalDispatcher immediately, we call `fetch` with an arguments and catch the error. We also need to wrap the fetch(<NO ARGS>) call itself, even though there's `.catch(...)`. This is because dd-trace throws an invalid URL error.
- Loading branch information
Showing
4 changed files
with
600 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.