Skip to content

logger is null when deployed in sveltekit app to Cloudflare pages #16711

Closed

Description

@jamemackson

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare

SDK Version

9.31.0

Framework Version

SvelteKit 2.16.0 - Svelte ^5.25.0 - Vite ^6.2.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

Everything works fine locally sending errors and logs to Sentry, but when deployed to cloudflare pages (v3 runtime with node compat flag) the Sentry objected imported seems uninitialized with only the following 4 constants set, but no methods or other properties that are visible from the same console.log messages when I'm working locally.

import * as Sentry from "@sentry/sveltekit";
const { logger } = Sentry;

export const GET = async () => {
  console.log("Sentry =>", Sentry);
  console.log("Sentry logger =>", logger);
  logger.info("Hello from Sentry! (server method)", {
    requestId: "123",
  });
  throw new Error("Sentry Example API Route Error");
};
(log) Sentry => {
  SDK_VERSION: '9.31.0',
  SEMANTIC_ATTRIBUTE_SENTRY_OP: 'sentry.op',
  SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN: 'sentry.origin',
  SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE: 'sentry.sample_rate',
  SEMANTIC_ATTRIBUTE_SENTRY_SOURCE: 'sentry.source'
}
(log) Sentry logger => null

has anyone else encountered this??

I've got an isolated example that exhibits the same behavior i encountered when implementing this in my real project here: https://github.com/spacethree/cloudflare-sveltekit-sentry

Steps to Reproduce

  1. deploy https://github.com/spacethree/cloudflare-sveltekit-sentry to cloudflare pages
  2. visit the deployed site's /sentry-example-page
  3. click "throw sample error button"

Expected Result

  1. Sentry object is debug logged on server with real methods and properties
  2. Sentry logger method is debug logged on server
  3. "Hello from Sentry! (server method)" should be sent to sentry logging with example structured data attached

Actual Result

  1. Sentry object only has the 4 properties (see above)
  2. Sentry logger is null
  3. access violation attempting to call logger.info

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 23, 2025
  2. self-assigned this
    on Jun 24, 2025
  3. RulaKhaled commented on Jun 24, 2025

    @RulaKhaled
    Collaborator

    Hello there, thanks for reaching out! I'm not a Cloudflare / SvelteKit expert, but I think the issue stems from a missing logger export in the SvelteKit worker environment that's used when deploying to Cloudflare Pages.
    I've added the missing logger export to the worker environment here #16716 , hopefully this should fix the issue. Once this is released, could you test this fix and let me know if it resolves the issue? If the problem persists, we can explore other approaches.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 24, 2025
  5. jamemackson commented on Jun 24, 2025

    @jamemackson
    Author

    Thanks @RulaKhaled that would certainly seem to be a part of the problem! In my case I am not seeing any methods on the Sentry object however so I wonder if there's still another issue upstream of the bug you found as well. I'm going to pull this code down and see if I can trace through and find what's going on. Seems like it should be something simple like what you found...

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 24, 2025
  7. jamemackson commented on Jun 24, 2025

    @jamemackson
    Author

    @RulaKhaled any idea when the next release will be?

  8. RulaKhaled commented on Jun 25, 2025

    @RulaKhaled
    Collaborator

    The issue might also be related to SvelteKit worker env, i will see what i can find out here.

    I am aiming to cut a release today or tomorrow.

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 25, 2025
  10. jamemackson commented on Jun 25, 2025

    @jamemackson
    Author

    @RulaKhaled I saw the release come out and pulled in the new version and I believe this has fixed the issue. I am now seeing logs flowing in from our Cloudflare pages instances! Thanks so much for the quick fix here!! 🎉

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions