Skip to content

Commit 04b220d

Browse files
authored
fix: remove redundant abort controller (#41)
The signal from this abort controller replaces any user-supplied signal in forward operations. When the user supplied signal aborts we call abort on the abort controller, aborting it's signal. We do not call `.abort()` on the abort controller for any other reason, therefore it can be removed and the user-supplied abort signal can be passed through unmodified. The redundant abort controller's signal also has the default limit on the number of event listeners so it causes `"possible EventEmitter memory leak detected"` warnings in node which people frequently mistake for an error and file issues about.
1 parent 50682bf commit 04b220d

1 file changed

Lines changed: 0 additions & 15 deletions

File tree

packages/verified-fetch/src/verified-fetch.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,6 @@ export class VerifiedFetch {
445445
[identity.code]: this.handleRaw
446446
}
447447

448-
/**
449-
*
450-
* TODO: Should we use 400, 408, 418, or 425, or throw and not even return a response?
451-
*/
452-
private async abortHandler (opController: AbortController): Promise<void> {
453-
this.log.error('signal aborted by user')
454-
opController.abort('signal aborted by user')
455-
}
456-
457448
/**
458449
* We're starting to get to the point where we need a queue or pipeline of
459450
* operations to perform and a single place to handle errors.
@@ -467,12 +458,6 @@ export class VerifiedFetch {
467458

468459
const options = convertOptions(opts)
469460

470-
const opController = new AbortController()
471-
if (options?.signal != null) {
472-
options.signal.onabort = this.abortHandler.bind(this, opController)
473-
options.signal = opController.signal
474-
}
475-
476461
options?.onProgress?.(new CustomProgressEvent<CIDDetail>('verified-fetch:request:start', { resource }))
477462

478463
// resolve the CID/path from the requested resource

0 commit comments

Comments
 (0)