Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crysmags committed May 8, 2024
1 parent 01cd0f6 commit 95ab17c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/web/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = requ
const { getGlobalDispatcher } = require('../../global')
const { webidl } = require('./webidl')
const { STATUS_CODES } = require('node:http')
const { resourceLimits } = require('node:worker_threads')
const GET_OR_HEAD = ['GET', 'HEAD']

const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esbuildDetection !== 'undefined'
Expand Down Expand Up @@ -123,11 +124,11 @@ class Fetch extends EE {
}

// This will publish all diagnostic events only when we have subscribers.
function ifSubscribersRunStores (request, input, init, callback) {
function ifSubscribersRunStores (req, input, init, callback) {
const hasSubscribers = subscribersCheck()

if (hasSubscribers) {
const context = { request, input, init, result: null, error: null }
const context = { req, input, init: init ?? {}, result: null, error: null }

return channels.start.runStores(context, () => {
try {
Expand Down Expand Up @@ -162,15 +163,15 @@ function createInstrumentedDeferredPromise (context) {
res = function (result) {
context.result = result
channels.asyncStart.runStores(context, () => {
resolve.apply(this, arguments)
resolve(resourceLimits)
channels.asyncEnd.publish(context)
})
}
rej = function (error) {
context.error = error
channels.error.publish(context)
channels.asyncStart.runStores(context, () => {
reject.apply(this, arguments)
reject(error)
channels.asyncEnd.publish(context)
})
}
Expand All @@ -180,7 +181,7 @@ function createInstrumentedDeferredPromise (context) {
}

// https://fetch.spec.whatwg.org/#fetch-method
function fetch (input, init = {}) {
function fetch (input, init = undefined) {
webidl.argumentLengthCheck(arguments, 1, { header: 'globalThis.fetch' })

// 2. Let requestObject be the result of invoking the initial value of
Expand Down

0 comments on commit 95ab17c

Please sign in to comment.