Skip to content

Commit

Permalink
chore(ext/web): use a non-resource stream for textDecoderStreamCleans…
Browse files Browse the repository at this point in the history
…UpOnCancel (denoland#21181)

Follow-up fix to denoland#21074
  • Loading branch information
mmastrac authored and zifeo committed Nov 22, 2023
1 parent 6804098 commit fee84e5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cli/tests/unit/text_encoding_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertThrows } from "./test_util.ts";
import {
assert,
assertEquals,
assertStrictEquals,
assertThrows,
} from "./test_util.ts";

Deno.test(function btoaSuccess() {
const text = "hello world";
Expand Down Expand Up @@ -323,9 +328,15 @@ Deno.test(function binaryEncode() {
Deno.test(
{ permissions: { read: true } },
async function textDecoderStreamCleansUpOnCancel() {
const filename = "cli/tests/testdata/assets/hello.txt";
const file = await Deno.open(filename);
const readable = file.readable.pipeThrough(new TextDecoderStream());
let cancelled = false;
const readable = new ReadableStream({
start: (controller) => {
controller.enqueue(new Uint8Array(12));
},
cancel: () => {
cancelled = true;
},
}).pipeThrough(new TextDecoderStream());
const chunks = [];
for await (const chunk of readable) {
chunks.push(chunk);
Expand All @@ -334,5 +345,6 @@ Deno.test(
}
assertEquals(chunks.length, 1);
assertEquals(chunks[0].length, 12);
assertStrictEquals(cancelled, true);
},
);

0 comments on commit fee84e5

Please sign in to comment.