Skip to content
File

Blob: src/workerd/api/tests/rpc-error-test.rpc.js

javascript46 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 { RpcTarget } from 'cloudflare:workers';
5 
6class Baz extends RpcTarget {
7 async qux() {
8 await scheduler.wait(10);
9 const err = new Error('bork');
10 err.stack2 = err.stack;
11 throw err;
12 }
13}
14 
15class Bar extends RpcTarget {
16 async baz() {
17 await scheduler.wait(10);
18 return new Baz();
19 }
20}
21 
22export default {
23 foo() {
24 const err = new Error('boom');
25 err.stack2 = err.stack;
26 throw err;
27 },
28 
29 async bar() {
30 await scheduler.wait(10);
31 return new Bar();
32 },
33 
34 xyz() {
35 const err = new Error('bang');
36 err.stack2 = err.stack;
37 return Promise.reject(err);
38 },
39 
40 abc() {
41 const err = new Error('boom');
42 err.stack2 = err.stack;
43 return { a: err };
44 },
45};