GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — In writable stream, should we always set `state.errorEmitted` to true when executing `stream.emit('error')`? · Issue #18181 · nodejs/node

In writable stream, should we always set state.errorEmitted to true when executing stream.emit('error')? #18181

New issue
Copy link
New issue
Copy link
Closed
Closed
In writable stream, should we always set state.errorEmitted to true when executing stream.emit('error')?#18181
Copy link

Description

@MoonBall
MoonBall
opened on Jan 16, 2018
Issue body actions

I have read the source code of lib/_stream_writable.js. I have a doubt about the meaning of state.errorEmitted.

Why do we set state.errorEmitted to true in some situations of stream.emit('error'), but doesn't set it in other situations. Moreover, it doesn't achieve emitting 'error' event only one time. For example, as shown below, the code will emit 'error' event two times :

const { Writable } = require('stream');

w = new Writable();
w.on('error', error => {
  console.log('on error.', error);
});
w.write(null);
w.write(null);

Activity

  1. MoonBall commented on Jan 17, 2018

    @MoonBall
    MoonBall
    on Jan 17, 2018
    MemberAuthor
    More actions

    @mcollina

  2. mcollina commented on Jan 17, 2018

    @mcollina
    mcollina
    on Jan 17, 2018
    SponsorMember
    More actions

    @MoonBall as a Node.js user, it means nothing. Internally it is used in some checks (in destroy()) to avoid doing certain things if the condition is met. This state variable is also used throughout core (which we should refactor according to #445).

    Making the change you propose is hard, but if you want to take a stab at it I will be happy review it.

  3. MoonBall commented on Jan 17, 2018

    @MoonBall
    MoonBall
    on Jan 17, 2018
    MemberAuthor
    More actions

    if it only work in destroy(), we can modify it's name or it's comments, so that we can better understand it. The comment(https://github.com/nodejs/node/blob/master/lib/_stream_writable.js#L144) is not appropriate.

  4. mcollina commented on Jan 17, 2018

    @mcollina
    mcollina
    on Jan 17, 2018
    SponsorMember
    More actions

    It is not just destroy: https://github.com/nodejs/node/search?utf8=%E2%9C%93&q=errorEmitted&type=.

    Ideally all of that should not be needed, would you like to investigate?

  5. MoonBall commented on Jan 18, 2018

    @MoonBall
    MoonBall
    on Jan 18, 2018
    MemberAuthor
    More actions

    ok. I try to do it.

  6. Trott commented on Nov 25, 2018

    @Trott
    Trott
    on Nov 25, 2018
    Member
    More actions

    /ping @MoonBall @mcollina Should this remain open?

  7. mcollina commented on Nov 26, 2018

    @mcollina
    mcollina
    on Nov 26, 2018
    SponsorMember
    More actions

    I think this should be closed.

  8. mcollina
    closed this as completedon Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.