ipfs / helia-verified-fetch

A fetch-like API for obtaining verified & trustless IPFS CIDs on the web
https://npmjs.com/package/@helia/verified-fetch
Other
14 stars 4 forks source link

fix: remove redundant abort controller #41

Closed achingbrain closed 5 months ago

achingbrain commented 6 months ago

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.

This manifests itself in helia-http-gateway as:

(node:58297) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
    at [kNewListener] (node:internal/event_target:572:17)
    at [kNewListener] (node:internal/abort_controller:241:24)
    at EventTarget.addEventListener (node:internal/event_target:685:23)
    at anySignal (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway-sessions/node_modules/any-signal/dist/src/index.js:21:20)
    at raceBlockRetrievers (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway-sessions/node_modules/@helia/utils/dist/src/utils/networked-storage.js:187:20)
    at NetworkedStorage.get (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway-sessions/node_modules/@helia/utils/dist/src/utils/networked-storage.js:87:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async BlockStorage.get (file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway-sessions/node_modules/@helia/utils/dist/src/storage.js:68:20)
    at async file:///Users/alex/Documents/Workspaces/ipfs/helia-http-gateway-sessions/node_modules/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js:60:27

Change checklist

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 1.3.5 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 1.13.0 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

github-actions[bot] commented 4 months ago

:tada: This PR is included in version 1.0.0 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket: