Skip to content

Commit

Permalink
fix(fetch): call the callback on destroy of Readable adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Nov 11, 2022
1 parent 6748f26 commit 188ac01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-ducks-design.md
@@ -0,0 +1,5 @@
---
'@whatwg-node/fetch': patch
---

Fix destroy for Node 18
5 changes: 3 additions & 2 deletions packages/fetch/dist/readableStreamToReadable.js
Expand Up @@ -12,13 +12,14 @@ module.exports = function readableStreamToReadable(readableStream) {
}
})
},
async destroy() {
async destroy(err, callback) {
try {
reader.cancel();
reader.releaseLock();
await readableStream.cancel();
callback();
} catch (error) {
console.log(error);
callback(error);
}
}
})
Expand Down

0 comments on commit 188ac01

Please sign in to comment.