Skip to content

Commit fdb1a5c

Browse files
author
Luca Forstner
authored
fix(nextjs): Apply server action data to correct isolation scope (#10514)
1 parent 01deeac commit fdb1a5c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/transactions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ test('Should send a transaction for instrumented server actions', async ({ page
130130
await page.getByText('Run Action').click();
131131

132132
expect(await serverComponentTransactionPromise).toBeDefined();
133-
expect(
134-
(await serverComponentTransactionPromise).contexts?.trace?.data?.['server_action_form_data.some-text-value'],
135-
).toEqual('some-default-value');
136-
expect((await serverComponentTransactionPromise).contexts?.trace?.data?.['server_action_result']).toEqual({
137-
city: 'Vienna',
133+
expect((await serverComponentTransactionPromise).extra).toMatchObject({
134+
'server_action_form_data.some-text-value': 'some-default-value',
135+
server_action_result: {
136+
city: 'Vienna',
137+
},
138138
});
139139

140140
expect(Object.keys((await serverComponentTransactionPromise).request?.headers || {}).length).toBeGreaterThan(0);

packages/nextjs/src/common/withServerActionInstrumentation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getIsolationScope } from '@sentry/core';
12
import {
23
addTracingExtensions,
34
captureException,
@@ -115,12 +116,12 @@ async function withServerActionInstrumentationImplementation<A extends (...args:
115116
});
116117

117118
if (options.recordResponse !== undefined ? options.recordResponse : sendDefaultPii) {
118-
isolationScope.setExtra('server_action_result', result);
119+
getIsolationScope().setExtra('server_action_result', result);
119120
}
120121

121122
if (options.formData) {
122123
options.formData.forEach((value, key) => {
123-
isolationScope.setExtra(
124+
getIsolationScope().setExtra(
124125
`server_action_form_data.${key}`,
125126
typeof value === 'string' ? value : '[non-string value]',
126127
);

0 commit comments

Comments
 (0)