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

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

Closed
zhuxb711 opened this issue Jul 31, 2024 · 4 comments · Fixed by #54142
Closed

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

zhuxb711 opened this issue Jul 31, 2024 · 4 comments · Fixed by #54142
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@zhuxb711
Copy link

zhuxb711 commented Jul 31, 2024

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

@jakecastelli jakecastelli added the stream Issues and PRs related to the stream subsystem. label Jul 31, 2024
@jakecastelli
Copy link
Contributor

Thanks for the report, the issue actually comes from memory-streams package using a very old implementation of the stream "readable-stream": "~1.0.2" and it does not know what pendingcb is on the WritableStream, therefore the Promise never resolved.

I could submit a patch at the meanwhile to fix this but please be mindful the package has been publicly archived.

@zhuxb711
Copy link
Author

Could suggest any alternative package for something like "in memory stream"?

targos pushed a commit that referenced this issue Aug 14, 2024
PR-URL: #54142
Fixes: #54131
Refs: #54131
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Sep 21, 2024
PR-URL: #54142
Fixes: #54131
Refs: #54131
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
targos pushed a commit that referenced this issue Oct 2, 2024
PR-URL: #54142
Fixes: #54131
Refs: #54131
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
@jakecastelli
Copy link
Contributor

This is fixed in the v20.18

@zhuxb711
Copy link
Author

zhuxb711 commented Oct 8, 2024

Thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants