Skip to content

[Nuxt] Server-side not reporting any errors (GCP Cloud Build / Cloud Run) #17165

Closed

Description

@azoom-julio-quiezi

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

9.40.0

Framework Version

3.17.7

Link to Sentry event

No response

Reproduction Example/SDK Setup

//nuxt.config.ts
export default defineNuxtConfig({
  compatibilityDate: '2024-11-01',
  devtools: { enabled: true },
  // other stuff
  modules: [
    '@sentry/nuxt/module',
    // other stuff
  ],
  runtimeConfig: {
    public: {
      sentryDsn: '',
    },
  },
  nitro: {
    esbuild: {
      options: {
        target: 'es2022',
      },
    },
  },
})
// sentry.server.config.ts
import process from 'node:process'
import * as Sentry from '@sentry/nuxt'

Sentry.init({
  dsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
  environment: process.env.APP_ENV,
  _experiments: { enableLogs: true },
  tracesSampleRate: 0.0,
  debug: true,
})
// sentry.client.config.ts
import * as Sentry from '@sentry/nuxt'

const config = useRuntimeConfig()

if (config.public.sentryDsn && config.public.sentryDsn !== '') {
  Sentry.init({
    dsn: config.public.sentryDsn,
    environment: config.public.environment,
    tracesSampleRate: 0.0,
  })
}
  // capture example
    Sentry.withScope((scope) => {
      scope.setExtra('email-error', emailResult.error)
      scope.setExtra('email-payload', {
        from: '',
        to: '',
        subject: emailTemplate.subject,
        service: '',
      })
      Sentry.captureMessage('Email sending failed in non-reporting API', 'error')
    })

Steps to Reproduce

We're experiencing an issue where Sentry notifications work perfectly in local development but fail to appear in our staging/production environment. Server-side Sentry events are not being captured or reported to the Sentry dashboard, however, client-side Sentry events are being captured or reported to the Sentry dashboard.

  1. Deploy the code using Cloud Build (GCP) and run using Cloud Run using Sentry.captureMessage as seen in the code snippet to capture messages from emails not sent.
  2. Intentionally remove the API from env files to get an error.
  3. Capture that error on Sentry Issues / Dashboard

Expected Result

I expected to capture the error in Sentry, but nothing appears on Dashboard.
Installed using pnpm.

What Works
✅ Local Development: Sentry captures all errors and sends notifications
✅ Client-side: Sentry works in both local and staging
✅ Configuration: Sentry is properly initialized (confirmed via debug logs)
✅ Environment Variables: DSN and environment are correctly set

What Doesn't Work
❌ Server-side in Staging: No Sentry notifications appear in dashboard
❌ Email failure events: Not captured in staging environment

Key Findings
Sentry Initialization: Confirmed working via server logs
Environment Variables: Properly set in staging
API Endpoints: Functioning correctly (return expected errors)
Server-side vs Client-side: Only server-side affected
Development vs Staging: Only staging environment affected
Event ID: When the error occurs, the event ID is shown, which means we are getting a response from Sentry (image below).

Image

Actual Result

No server-side issues are seen in the Dashboard, despite having a response from Sentry with the Event ID when errors happen on staging environment (Cloud Build / Cloud Run).

But works fine on local machine.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 25, 2025
  2. s1gr1d commented on Jul 25, 2025

    @s1gr1d
    Member

    Hello, and thanks for the descriptive issue!

    It could be that the serverless function runtime is not long enough to still send the event to Sentry. I added a PR that will also detect a Google Could Run runtime: #17168

    Do you get other logs from Sentry as well?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 25, 2025
  4. azoom-julio-quiezi commented on Jul 28, 2025

    @azoom-julio-quiezi
    Author

    @s1gr1d
    Hello, thanks for the response.

    I have not tried any other logs from Sentry, only Event ID.
    By the way, the Event ID is generated on my system and then sent to Sentry? How does the the Event ID generation process work?
    Also, what logs do you think would be helpful?

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 28, 2025
  6. s1gr1d commented on Jul 28, 2025

    @s1gr1d
    Member

    The event ID is usually generated by the SDK when an error occurs in captureException here.

    When starting the server you should see logs like these below (shortened). Do you see those?

    Sentry Logger [log]: Initializing Sentry: process: 58849, thread: main.
    Sentry Logger [log]: Integration installed: InboundFilters
    Sentry Logger [log]: Integration installed: FunctionToString
    Sentry Logger [log]: Integration installed: LinkedErrors
    Sentry Logger [log]: Integration installed: RequestData
    Sentry Logger [log]: Integration installed: Console
    Sentry Logger [log]: Integration installed: NodeFetch
    ...
    Sentry Logger [log]: Integration installed: Http
    Sentry Logger [log]: Running in ESM mode.
    Sentry Logger [debug]: @opentelemetry/api: Registered a global for trace v1.9.0.
    ...
    Sentry Logger [debug]: @sentry/instrumentation-http Applying instrumentation patch for nodejs core module on require hook { module: 'https' }
    

    And on request:

    Sentry Logger [log]: [Tracing] Finishing "< unknown op >" root span "GET /api/example/:param" with ID <someSpanID>
    Sentry Logger [log]: SpanExporter exported 1 spans, 0 spans are waiting for their parent spans to finish
  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 28, 2025
  8. moved this to Waiting for: Community in GitHub Issues with 👀 3on Jul 28, 2025
  9. s1gr1d commented on Aug 4, 2025

    @s1gr1d
    Member

    Does it work when you upgrade to the latest version of the SDK?

  10. azoom-julio-quiezi commented on Aug 15, 2025

    @azoom-julio-quiezi
    Author

    @s1gr1d
    Hello, sorry for the late reply, I was working on another project.

    Today I started working on this issue again and I could resolve it.
    The issue was a combination of two factors:

    1. Lack of Initializing Sentry with --import
    2. Using import process from 'node:process' in sentry.server.config.ts

    For some reason, adding import process from 'node:process' causes it to be duplicated when the app tries to import server-side configuration, as seen in the log below extracted from Logging in GCP, finally causing a syntax error.
    After removing it, the issue was fixed.

    2025-08-15 16:41:59.206
    Starting new instance. Reason: MANUAL_OR_CUSTOMER_MIN_INSTANCE - Instance started because of customer-configured min-instances or manual scaling.
    2025-08-15 16:42:00.014
    file:///app/.output/server/sentry.server.config.mjs:1
    2025-08-15 16:42:00.014
    import process from 'node:process';globalThis._importMeta_={url:import.meta.url,env:process.env};;{try{(function(){var e="undefined"!="undefined"?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c8df08c4-b463-414a-90a4-d0dc40281bd1",e._sentryDebugIdIdentifier="sentry-dbid-c8df08c4-b463-414a-90a4-d0dc40281bd1");})();}catch(e){}};import process from 'node:process';
    2025-08-15 16:42:00.014
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ^^^^^^^^^^^^^^
    2025-08-15 16:42:00.014
    SyntaxError: Identifier 'process' has already been declared     at compileSourceTextModule (node:internal/modules/esm/utils:346:16)     at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:146:18)
    2025-08-15 16:42:00.014
        at #translate (node:internal/modules/esm/loader:431:12)
    2025-08-15 16:42:00.014
        at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:478:27)
    2025-08-15 16:42:00.014
        at async ModuleJob._link (node:internal/modules/esm/module_job:110:19)
    2025-08-15 16:42:00.014
    Node.js v20.19.4
    2025-08-15 16:42:00.419
    Container called exit(1).
    2025-08-15 16:42:00.583
    Default STARTUP TCP probe failed 1 time consecutively for container "test-sentry-1" on port 8080. The instance was not started. Connection failed with status CANCELLED.
    

    At this point, I cannot tell if this a Sentry SDK issue or GCP Cloud Build issue.

  11. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 15, 2025
  12. s1gr1d commented on Aug 19, 2025

    @s1gr1d
    Member

    Good to hear that it works for you now!

    The import from process and globalThis._importMeta_ comes from Nitro. As process is already imported, you don't have to do it a second time.

    Does it work for you when you remove the process import? I'll close the issue now, but I can open it again if there's still an issue.

  13. azoom-julio-quiezi commented on Aug 19, 2025

    @azoom-julio-quiezi
    Author

    Good to hear that it works for you now!

    The import from process and globalThis._importMeta_ comes from Nitro. As process is already imported, you don't have to do it a second time.

    Does it work for you when you remove the process import? I'll close the issue now, but I can open it again if there's still an issue.

    Yes, it does work.
    I think it is safe to close the issue, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions