-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
64 lines (59 loc) · 2.06 KB
/
test.ts
File metadata and controls
64 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { expect, it } from 'vitest';
import { createRunner } from '../../../runner';
it('traces a durable object method', async ({ signal }) => {
const runner = createRunner(__dirname)
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1];
expect(transactionEvent).toEqual(
expect.objectContaining({
contexts: expect.objectContaining({
trace: expect.objectContaining({
op: 'rpc',
data: expect.objectContaining({
'sentry.op': 'rpc',
'sentry.origin': 'auto.faas.cloudflare.durable_object',
}),
origin: 'auto.faas.cloudflare.durable_object',
}),
}),
transaction: 'sayHello',
}),
);
})
.start(signal);
await runner.makeRequest('get', '/hello');
await runner.completed();
});
// Regression test for https://github.com/getsentry/sentry-javascript/issues/17127
// The RPC receiver does not implement the method error on consecutive calls
it('handles consecutive RPC calls without throwing "RPC receiver does not implement method" error', async ({
signal,
}) => {
const runner = createRunner(__dirname)
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1];
expect(transactionEvent).toEqual(
expect.objectContaining({
transaction: 'sayHello',
}),
);
})
.expect(envelope => {
const transactionEvent = envelope[1]?.[0]?.[1];
expect(transactionEvent).toEqual(
expect.objectContaining({
transaction: 'sayHello',
}),
);
})
.unordered()
.start(signal);
// First request - this always worked
const response1 = await runner.makeRequest<string>('get', '/hello');
expect(response1).toBe('Hello, world');
// Second consecutive request - this used to fail with:
// "The RPC receiver does not implement the method 'sayHello'"
const response2 = await runner.makeRequest<string>('get', '/hello');
expect(response2).toBe('Hello, world');
await runner.completed();
});