File
Blob: src/workerd/api/tests/leak-fetch-test.js
| 1 | // Copyright (c) 2025 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 |
| 4 | // Test should not fail with a memory leak reported by ASAN. |
| 5 | // Failures here would only occur in an ASAN build. |
| 6 | |
| 7 | export const memoryLeak = { |
| 8 | async test(_ctrl, env) { |
| 9 | { |
| 10 | (await env.subrequest.fetch('http://example.org')).body.pipeTo( |
| 11 | new WritableStream() |
| 12 | ); |
| 13 | } |
| 14 | globalThis.gc(); |
| 15 | globalThis.gc(); |
| 16 | }, |
| 17 | }; |
| 18 | |
| 19 | export const memoryLeak2 = { |
| 20 | async test(_ctrl, env) { |
| 21 | { |
| 22 | new ReadableStream().pipeTo(new WritableStream()); |
| 23 | } |
| 24 | globalThis.gc(); |
| 25 | globalThis.gc(); |
| 26 | }, |
| 27 | }; |
| 28 | |
| 29 | export const memoryLeak3 = { |
| 30 | async test(_ctrl, env) { |
| 31 | { |
| 32 | new ReadableStream().pipeTo(new IdentityTransformStream().writable); |
| 33 | } |
| 34 | globalThis.gc(); |
| 35 | globalThis.gc(); |
| 36 | }, |
| 37 | }; |
| 38 | |
| 39 | export default { |
| 40 | async fetch() { |
| 41 | await scheduler.wait(1_000); |
| 42 | return new Response('ok'); |
| 43 | }, |
| 44 | }; |