Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crysmags committed May 9, 2024
1 parent b9dc1ff commit 3fed3a8
Showing 1 changed file with 0 additions and 120 deletions.
120 changes: 0 additions & 120 deletions lib/web/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,6 @@ class Fetch extends EE {
}
}

<<<<<<< HEAD
function handleFetchDone (response) {
finalizeAndReportTiming(response, 'fetch')
}

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

// 1. Let p be a new promise.
let p = createDeferredPromise()
=======
// This will publish all diagnostic events only when we have subscribers.
function ifSubscribersRunStores (req, input, init, callback) {
const hasSubscribers = subscribersCheck()
Expand Down Expand Up @@ -194,7 +182,6 @@ function createInstrumentedDeferredPromise (context) {
// https://fetch.spec.whatwg.org/#fetch-method
function fetch (input, init = undefined) {
webidl.argumentLengthCheck(arguments, 1, { header: 'globalThis.fetch' })
>>>>>>> 01cd0f6e (Diagnostics channel support)

// 2. Let requestObject be the result of invoking the initial value of
// Request as constructor with input and init as arguments. If this throws
Expand Down Expand Up @@ -312,113 +299,6 @@ function fetch (input, init = undefined) {
})
// 14. Return p.
return p.promise
<<<<<<< HEAD
}

// 3. Let request be requestObject’s request.
const request = requestObject[kState]

// 4. If requestObject’s signal’s aborted flag is set, then:
if (requestObject.signal.aborted) {
// 1. Abort the fetch() call with p, request, null, and
// requestObject’s signal’s abort reason.
abortFetch(p, request, null, requestObject.signal.reason)

// 2. Return p.
return p.promise
}

// 5. Let globalObject be request’s client’s global object.
const globalObject = request.client.globalObject

// 6. If globalObject is a ServiceWorkerGlobalScope object, then set
// request’s service-workers mode to "none".
if (globalObject?.constructor?.name === 'ServiceWorkerGlobalScope') {
request.serviceWorkers = 'none'
}

// 7. Let responseObject be null.
let responseObject = null

// 8. Let relevantRealm be this’s relevant Realm.

// 9. Let locallyAborted be false.
let locallyAborted = false

// 10. Let controller be null.
let controller = null

// 11. Add the following abort steps to requestObject’s signal:
addAbortListener(
requestObject.signal,
() => {
// 1. Set locallyAborted to true.
locallyAborted = true

// 2. Assert: controller is non-null.
assert(controller != null)

// 3. Abort controller with requestObject’s signal’s abort reason.
controller.abort(requestObject.signal.reason)

const realResponse = responseObject?.deref()

// 4. Abort the fetch() call with p, request, responseObject,
// and requestObject’s signal’s abort reason.
abortFetch(p, request, realResponse, requestObject.signal.reason)
}
)

// 12. Let handleFetchDone given response response be to finalize and
// report timing with response, globalObject, and "fetch".
// see function handleFetchDone

// 13. Set controller to the result of calling fetch given request,
// with processResponseEndOfBody set to handleFetchDone, and processResponse
// given response being these substeps:

const processResponse = (response) => {
// 1. If locallyAborted is true, terminate these substeps.
if (locallyAborted) {
return
}

// 2. If response’s aborted flag is set, then:
if (response.aborted) {
// 1. Let deserializedError be the result of deserialize a serialized
// abort reason given controller’s serialized abort reason and
// relevantRealm.

// 2. Abort the fetch() call with p, request, responseObject, and
// deserializedError.

abortFetch(p, request, responseObject, controller.serializedAbortReason)
return
}

// 3. If response is a network error, then reject p with a TypeError
// and terminate these substeps.
if (response.type === 'error') {
p.reject(new TypeError('fetch failed', { cause: response.error }))
return
}

// 4. Set responseObject to the result of creating a Response object,
// given response, "immutable", and relevantRealm.
responseObject = new WeakRef(fromInnerResponse(response, 'immutable'))

// 5. Resolve p with responseObject.
p.resolve(responseObject.deref())
p = null
}

controller = fetching({
request,
processResponseEndOfBody: handleFetchDone,
processResponse,
dispatcher: requestObject[kDispatcher] // undici
=======
>>>>>>> 01cd0f6e (Diagnostics channel support)
})
}

Expand Down

0 comments on commit 3fed3a8

Please sign in to comment.