Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.
This repository was archived by the owner on May 18, 2026. It is now read-only.

Prevent Interference with Task Streams #3

Description

@thejmazz

Task will return a readable, writable, or duplex stream. However, then the user, if they are making mischief, can interfere. Perhaps there is a use case for this, and it should just be advised to be avoided to not use stream methods on the streams that Task returns. Consider:

const config = {
  sraAccession: '2492428',
  referenceURL: 'http://ftp.ncbi.nlm.nih.gov/genomes/all/GCA_000988525.2_ASM98852v2/GCA_000988525.2_ASM98852v2_genomic.fna.gz'
}

// TODO take in an object stream to start off a bunch of these
const downloadReference = Task({
  input: config.referenceURL,
  output: new File(config.referenceURL.split('/').pop())
}, ({ input, output }) => request(input).pipe(fs.createWriteStream(output.value)) )

const s = downloadReference()
s.write('FOOBAR') // This gets written to the reference.gz file (and corrupts it)
s.on('finish', () => console.log('File written'))

Moreover something to keep in mind; probably not worthwhile finding a way to enforce this cannot happen instead of just advising to users to not do it unless they know what they are doing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions