MCPcopy Create free account
hub / github.com/nodejs/node / buildAbort

Function buildAbort

deps/undici/src/lib/web/fetch/request.js:47–83  ·  view source on GitHub ↗
(acRef)

Source from the content-addressed store, hash-verified

45}
46
47function buildAbort (acRef) {
48 return abort
49
50 function abort () {
51 const ac = acRef.deref()
52 if (ac !== undefined) {
53 // Currently, there is a problem with FinalizationRegistry.
54 // https://github.com/nodejs/node/issues/49344
55 // https://github.com/nodejs/node/issues/47748
56 // In the case of abort, the first step is to unregister from it.
57 // If the controller can refer to it, it is still registered.
58 // It will be removed in the future.
59 requestFinalizer.unregister(abort)
60
61 // Unsubscribe a listener.
62 // FinalizationRegistry will no longer be called, so this must be done.
63 this.removeEventListener('abort', abort)
64
65 ac.abort(this.reason)
66
67 const controllerList = dependentControllerMap.get(ac.signal)
68
69 if (controllerList !== undefined) {
70 if (controllerList.size !== 0) {
71 for (const ref of controllerList) {
72 const ctrl = ref.deref()
73 if (ctrl !== undefined) {
74 ctrl.abort(this.reason)
75 }
76 }
77 controllerList.clear()
78 }
79 dependentControllerMap.delete(ac.signal)
80 }
81 }
82 }
83}
84
85let patchMethodWarning = false
86

Callers 2

constructorMethod · 0.70
cloneMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected