#Nuxt + AWS Lambda: Sentry SSR events not showing up

6 messages · Page 1 of 1 (latest)

calm elk
#

Hi everyone,

we’re running into an issue with Sentry in a Nuxt application deployed on AWS Lambda.

In development mode, everything works as expected. However, once we build the app using the AWS Lambda preset and deploy it, we notice the following behavior:

We do receive data from direct API calls
We do receive browser tracing data (CSR)
But we do NOT receive any data from SSR requests

So it seems like Sentry is not capturing or sending events during server-side rendering in the Lambda environment.

Has anyone experienced something similar or has any ideas what might be causing this?

Thanks in advance!

quaint wedge
#

Do you see any errors/warnings in the lambda logs? If not, try redeploying with debug: true in your Sentry.init and see if there's anything logged out. Let me know what you see.

In the meantime, make sure you're using the CLI import to bring Sentry in. This preloads the Sentry config before the application runs. If it's not setup correctly, SSR events won't be captured.

Learn how to use the node --import CLI flag.

calm elk
# quaint wedge Do you see any errors/warnings in the lambda logs? If not, try redeploying with ...

Sorry for the late response.
We enabled debug: true and confirmed that Sentry is definitely initialized in Lambda.

We’ve also verified:

  • CLI import (--import) is in place
  • we additionally tested with the Sentry Lambda Layer
  • no relevant errors/warnings in the Lambda logs besides Sentry debug output

What we’re currently seeing is:

  • We do get root HTTP transactions such as GET /[slug]
  • however, those transactions do not contain the expected SSR / middleware spans
  • instead, middleware-like entries such as 00.ignore, 01.redirect, 02.auth, 03.getUserLangSettings, 04.queryObjects, etc. appear as separate transactions
  • those separate transactions are then dropped by NuxtLowQualityTransactionsFilter

An additional interesting detail is that even our manual spans are ingested, but they also show up without a parent.
That seems to suggest the issue is not limited to the automatic middleware instrumentation, but that the active parent/root span context is generally not preserved or available when SSR-related work is executed.

So the issue does not seem to be that Sentry is missing entirely or that no HTTP root transactions are created.
Rather, the SSR-related spans do not seem to be attached to the existing HTTP root transaction and instead become standalone transactions.

We have also checked our infrastructure configuration and sentry-trace / baggage should be forwarded through CloudFront / API Gateway.

Given this, do you have any ideas what could cause spans in a Nuxt + Nitro aws_lambda setup to lose their parent / active context and become standalone transactions instead of child spans of the HTTP request transaction?

Would you expect any special handling or known limitations around async context propagation in Lambda / Nitro here?

quaint wedge
woeful cradle
#

Hey there 👋

The low quality transaction are actually the middleware spans, but they should be nested under a root span, so this is probably the same issue you are facing with the root span being missing.

Can you tell me when did this start happening for you? Also which SDK version/nuxt version are you on at the moment.

calm elk