MCPcopy Create free account
hub / github.com/nodejs/undici / onResponseError

Method onResponseError

lib/api/api-request.js:186–218  ·  view source on GitHub ↗
(_controller, err)

Source from the content-addressed store, hash-verified

184 }
185
186 onResponseError (_controller, err) {
187 const { res, callback, body, opaque } = this
188
189 if (callback) {
190 // TODO: Does this need queueMicrotask?
191 this.callback = null
192 queueMicrotask(() => {
193 this.runInAsyncScope(callback, null, err, { opaque })
194 })
195 }
196
197 if (res) {
198 this.res = null
199 // Ensure all queued handlers are invoked before destroying res.
200 queueMicrotask(() => {
201 util.destroy(res.on('error', noop), err)
202 })
203 }
204
205 if (body) {
206 this.body = null
207
208 if (util.isStream(body)) {
209 body.on('error', noop)
210 util.destroy(body, err)
211 }
212 }
213
214 if (this.removeAbortListener) {
215 this.removeAbortListener()
216 this.removeAbortListener = null
217 }
218 }
219}
220
221function request (opts, callback) {

Callers

nothing calls this directly

Calls 2

destroyMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected