Skip to content
Discussion options

You must be logged in to vote

the JSSTREAM warning is actually a false positive from Jest's --detectOpenHandles - its related to http2-wrapper's global connection pool, not your file stream (see issue #2288).

your cleanup code looks correct. got will destroy the stream when the request completes. just make sure to await the request before closing the fileHandle:

try {
  const fileStream = fileHandle.createReadStream({
    start: this.chunkStartPosition,
    end: this.chunkStartPosition + this.chunkLengthInBytes - 1
  });
  
  await gotInstance.post(this.uploadUrl, { body: fileStream });
} finally {
  await fileHandle?.close(); // await this
}

to fix the Jest warning, either:

  1. remove the --detectOpenHandles flag
  2. set ht…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sindresorhus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants