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

Writable streams are never closed when using web workers #341

Closed
0f-0b opened this issue Jul 9, 2022 · 3 comments
Closed

Writable streams are never closed when using web workers #341

0f-0b opened this issue Jul 9, 2022 · 3 comments
Labels

Comments

@0f-0b
Copy link
Contributor

0f-0b commented Jul 9, 2022

As a reproduction, the following code does not log close to the console.

const zip = new Uint8Array([
  0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x02, 0x00,
  0x08, 0x00, 0xb1, 0x15, 0xea, 0x54, 0x2e, 0xf9,
  0xb0, 0x5d, 0x19, 0x00, 0x00, 0x00, 0xb0, 0x04,
  0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x68, 0x65,
  0x6c, 0x6c, 0x6f, 0x2e, 0x74, 0x78, 0x74, 0xcb,
  0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, 0x2f,
  0xca, 0x49, 0xe1, 0xca, 0x18, 0x65, 0x8f, 0xb2,
  0x47, 0xd9, 0xa3, 0xec, 0x41, 0xcc, 0x06, 0x00,
  0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x14, 0x00,
  0x02, 0x00, 0x08, 0x00, 0xb1, 0x15, 0xea, 0x54,
  0x2e, 0xf9, 0xb0, 0x5d, 0x19, 0x00, 0x00, 0x00,
  0xb0, 0x04, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0xa4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x68, 0x65,
  0x6c, 0x6c, 0x6f, 0x2e, 0x74, 0x78, 0x74, 0x50,
  0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01,
  0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x40,
  0x00, 0x00, 0x00, 0x00, 0x00,
]);
const reader = new ZipReader(new Uint8ArrayReader(zip));
for await (const entry of reader.getEntriesGenerator()) {
  const writable = new WritableStream({
    close() {
      console.log("close");
    },
  });
  await entry.getData(new WritableStreamWriter(writable));
}
@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Jul 9, 2022

I agree that WritableStreamWriter needs more work and more tests. I don't recommend using it right now (unfortunately).

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Jul 10, 2022

It's fixed in the version 2.5.9. WritableStreamWriter should work as expected now.

gildas-lormeau added a commit that referenced this issue Jul 10, 2022
@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Jul 13, 2022

For the record, you can now write await entry.getData({ writable }); instead of await entry.getData(new WritableStreamWriter(writable)); since the version 2.5.19.

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

No branches or pull requests

2 participants