Skip to content

Commit

Permalink
lib: fix the name of the fetch global function
Browse files Browse the repository at this point in the history
PR-URL: #53227
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
  • Loading branch information
dygabo authored and marco-ippolito committed Jul 19, 2024
1 parent 9d3699b commit 57d7bbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/web/exposed-window-or-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ObjectDefineProperty(globalThis, 'fetch', {
configurable: true,
enumerable: true,
writable: true,
value: function value(input, init = undefined) {
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;
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ for (const moduleName of builtinModules) {
'crypto',
];
assert.deepStrictEqual(new Set(Object.keys(global)), new Set(expected));
expected.forEach((value) => {
const desc = Object.getOwnPropertyDescriptor(global, value);
if (typeof desc.value === 'function') {
assert.strictEqual(desc.value.name, value);
} else if (typeof desc.get === 'function') {
assert.strictEqual(desc.get.name, `get ${value}`);
}
});
}

common.allowGlobals('bar', 'foo');
Expand Down

0 comments on commit 57d7bbf

Please sign in to comment.