Skip to content

stream/promise finished behavior changed when upgrade from 20.13.1 to 20.16.0 #54131

Closed
@zhuxb711

Description

@zhuxb711

Version

20.16.0

Platform

UNIX & Windows

Subsystem

No response

What steps will reproduce the bug?

I use he archiver from package "archiver": "^7.0.1" and try to archive some files to a stream. I use finished function to wait for the stream completed.

import archiver from 'archiver';
import * as memoryStream from 'memory-streams';
import * as streamPromise from 'stream/promises';

function dosomething() {
    const highWaterMark = 8 * 1024 * 1024;
    const zipStream = new memoryStream.WritableStream({
      emitClose: true,
      autoDestroy: true,
      highWaterMark: highWaterMark
    });
    
    const zipArchiver = archiver.create('zip', {
      zlib: {
        level: 9
      },
      highWaterMark: highWaterMark
    });
    
    zipArchiver.pipe(zipStream);
    zipArchiver.on('error', (err) => {
      // Print error
    });
    zipArchiver.on('warning', (err) => {
      // Print warning
    });
    
    // Append some entries to the archive
    zipArchiver.append(/*<ReadableStream or buffer>*/, {
      name: 'test',
      date: new Date()
    });
    
    await zipArchiver.finalize();
    
    // Node.js v20.13.1 this function will return
    // Node.js v20.16.0 this function will never return
    await streamPromise.finished(zipStream);
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

finished should behave as the Nodejs v20.13.1

What do you see instead?

finished never returns

Additional information

No response

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