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

Multiple end() calls should throw an error #44

Open
martinheidegger opened this issue May 19, 2021 · 1 comment
Open

Multiple end() calls should throw an error #44

martinheidegger opened this issue May 19, 2021 · 1 comment

Comments

@martinheidegger
Copy link
Contributor

martinheidegger commented May 19, 2021

The following test currently fails:

tape('repeat calls to .end() should cause an error', function (t) {
  t.plan(4)
  const s = new Writable({
    write (data, cb) {
      t.equals(data, 'a')
      cb()
    }
  })
  s.on('error', function () {
    t.pass('Error called by multiple end calls')
  })
  s.on('close', function () {
    t.end()
  })
  t.equals(s.writable, true)
  s.end('a')
  t.equals(s.writable, false)
  s.end('b')
}

For one, the write method is called for both end() calls and there is no error caused when this is executed.
I noted this as incompatibility to the current Node.js streams and am wondering: is that intentional? should that be documented?

@mafintosh
Copy link
Owner

Yea, always found it very weird how Node.js streams forward user errors as stream.on('errors'). Makes it really hard in practice to find programming issues / runtime stream errors.

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

Successfully merging a pull request may close this issue.

2 participants