Skip to content
File

Blob: src/workerd/api/tests/abort-internal-streams-test.js

javascript27 lines
1// Copyright (c) 2024 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4import { strictEqual } from 'assert';
5 
6export const abortInternalStreamsTest = {
7 async test() {
8 const { writable } = new IdentityTransformStream();
9 
10 const writer = writable.getWriter();
11 
12 const promise = writer.write(new Uint8Array(10));
13 
14 await writer.abort();
15 
16 // The write promise should abort proactively without waiting for a read,
17 // indicating that the queue was drained proactively when the abort was
18 // called.
19 try {
20 await promise;
21 throw new Error('The promise should have been rejected');
22 } catch (err) {
23 strictEqual(err, undefined);
24 }
25 },
26};