Skip to content

pipeline does not wait for full stream destruction #23214

Closed
@ronag

Description

@ronag

Related to #23133.

Even if we change so that open is emitted before destroy. pipeline will not wait for completed destruction for all streams. Which can cause subtle bugs with things like:

const rec = db.getRecord(blockId)
pipeline(
  req, 
  fs.createWriteStream(blockPath, { flags: 'wx' })
    .on('open', () => {
      // Oops, this can be called after rec.destroy() :/. I didn't expect that.
      rec.set({
        path: blockPath
      })
    }),
  err => {
    rec.destroy()
    callback(err)
  }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions