Skip to content

Commit 46449a7

Browse files
committed
new test
1 parent 1a415bb commit 46449a7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/javascript/tests/before-send.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ describe('beforeSend', () => {
142142
);
143143
});
144144

145+
it('should still send event when structuredClone throws (non-cloneable payload)', async () => {
146+
// Arrange
147+
const { sendSpy, transport } = createTransport();
148+
const hawk = createCatcher(transport, (event) => event);
149+
const cloneSpy = vi.spyOn(globalThis, 'structuredClone').mockImplementation(() => {
150+
throw new DOMException('could not be cloned', 'DataCloneError');
151+
});
152+
153+
// Act
154+
hawk.send(new Error('non-cloneable'));
155+
await wait();
156+
157+
// Assert — event is still sent, reporting didn't crash
158+
expect(sendSpy).toHaveBeenCalledOnce();
159+
expect(getSentPayload(sendSpy)!.title).toBe('non-cloneable');
160+
161+
cloneSpy.mockRestore();
162+
});
163+
145164
it('should send event without deleted optional fields', async () => {
146165
// Arrange
147166
const { sendSpy, transport } = createTransport();

0 commit comments

Comments
 (0)