Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Interference with Task Streams #3

Closed
thejmazz opened this issue Jun 28, 2016 · 0 comments
Closed

Prevent Interference with Task Streams #3

thejmazz opened this issue Jun 28, 2016 · 0 comments
Assignees
Labels

Comments

@thejmazz
Copy link
Member

thejmazz commented Jun 28, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants