Skip to content
File

Blob: src/workerd/api/tests/request-signal-disabled.js

javascript33 lines
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
4import { WorkerEntrypoint } from 'cloudflare:workers';
5import assert from 'node:assert';
6export class OtherServer extends WorkerEntrypoint {
7 async fetch() {
8 await scheduler.wait(300);
9 return new Response('completed');
10 }
11 
12 async rpcEcho(req) {
13 return req;
14 }
15}
16export class Server extends WorkerEntrypoint {
17 async fetch(req) {
18 const _resSameRequest = await this.env.OtherServer.rpcEcho(req);
19 const _resNewRequest = await this.env.OtherServer.rpcEcho(new Request(req));
20 const _resClonedRequest = await this.env.OtherServer.rpcEcho(req.clone());
21 
22 return new Response('ok');
23 }
24}
25 
26export const incomingRequestSignalCanBeCloned = {
27 async test(ctrl, env, ctx) {
28 const req = env.Server.fetch('http://example.com/cloneIncomingRequest');
29 const res = await req;
30 assert.strictEqual(await res.text(), 'ok');
31 },
32};