Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa250fd

Browse filesBrowse files
authored
lib: make fetch sync and return a Promise
update test PR-URL: #49936 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 6c9625d commit fa250fd
Copy full SHA for fa250fd

File tree

Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/pre_execution.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/pre_execution.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ function setupUndici() {
292292
}
293293

294294
if (!getOptionValue('--no-experimental-fetch')) {
295-
async function fetch(input, init = undefined) {
295+
// Fetch is meant to return a Promise, but not be async.
296+
function fetch(input, init = undefined) {
296297
return lazyUndici().fetch(input, init);
297298
}
298299

Collapse file

‎test/parallel/test-fetch.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-fetch.mjs
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ assert.strictEqual(typeof globalThis.Headers, 'function');
1010
assert.strictEqual(typeof globalThis.Request, 'function');
1111
assert.strictEqual(typeof globalThis.Response, 'function');
1212

13+
{
14+
const asyncFunction = async function() {}.constructor;
15+
16+
assert.ok(!(fetch instanceof asyncFunction));
17+
assert.notStrictEqual(Reflect.getPrototypeOf(fetch), Reflect.getPrototypeOf(async function() {}));
18+
assert.strictEqual(Reflect.getPrototypeOf(fetch), Reflect.getPrototypeOf(function() {}));
19+
}
20+
1321
const server = http.createServer(common.mustCall((req, res) => {
1422
res.end('Hello world');
1523
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.