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

chore(ext/web): use a non-resource stream for textDecoderStreamCleansUpOnCancel #21181

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
},
);