diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js index f120f371d9b634..2be86f907bd47c 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -292,7 +292,8 @@ function setupUndici() { } if (!getOptionValue('--no-experimental-fetch')) { - async function fetch(input, init = undefined) { + // Fetch is meant to return a Promise, but not be async. + function fetch(input, init = undefined) { return lazyUndici().fetch(input, init); } diff --git a/test/parallel/test-fetch.mjs b/test/parallel/test-fetch.mjs index e24a38eb27db37..c1a030a7d2eac2 100644 --- a/test/parallel/test-fetch.mjs +++ b/test/parallel/test-fetch.mjs @@ -10,6 +10,12 @@ assert.strictEqual(typeof globalThis.Headers, 'function'); assert.strictEqual(typeof globalThis.Request, 'function'); assert.strictEqual(typeof globalThis.Response, 'function'); +{ + const asyncFunction = async function() {}.constructor; + + assert.ok(!(fetch instanceof asyncFunction)); +} + const server = http.createServer(common.mustCall((req, res) => { res.end('Hello world'); }));