-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
10.22.0
Framework Version
@sentry/react 10.22.0
Link to Sentry event
API: https://jervis-webb-company.sentry.io/issues/6987688505/events/2bec74dd8d694a35a0dbebb4152e627e/, client: https://jervis-webb-company.sentry.io/issues/6987688558/events/565d36470aca4183802799c63bf41426/
Reproduction Example/SDK Setup
Lambda code hosts a TRPC server, is bundled via esbuild and deployed behind API Gateway and routed via a Cloudfront function to have the same origin as frontend.
Lambda init
// Creates TRPC context
const createContext = async ({ event, context }: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2>) => {
...
};
Sentry.init({
enabled: true,
dsn: process.env.SENTRY_DSN,
sendDefaultPii: true,
sampleRate: 1.0,
tracesSampleRate: 1.0,
});
// TRPC lambda adapter
const inner = awsLambdaRequestHandler({
router: appRouter,
createContext,
onError: (opts) => {
const { error } = opts;
logger.error(error, "TRPC error");
if (error.code === "INTERNAL_SERVER_ERROR") {
throw error;
}
},
});
export const handler = Sentry.wrapHandler(inner);Frontend init
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
sendDefaultPii: true,
integrations: [
Sentry.replayIntegration({
blockAllMedia: false,
maskAllText: false,
}),
Sentry.tanstackRouterBrowserTracingIntegration(router),
],
tracesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
});Steps to Reproduce
- Deploy a lambda TRPC function behind API gateway and Cloudfront function for routing.
- Create a client that calls a TRPC route that errors out.
Expected Result
Distributed tracing should work out of the box.
Actual Result
Distributed tracing doesn't work.
You can see in the Sentry issues linked above, that the server event receives the necessary headers (entire event logged as context), and that it matches the trace ID sent from client. However, the API issue creates a new trace ID anyways. Notably, the url tag is also empty, but I don't know if this is because it's not something in the Lambda event.
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status