Skip to content

Compatibility of @sentry/astro with Cloudflare Pages #13217

@mariusbolik

Description

@mariusbolik

Problem Statement

I installed the @sentry/astro integration in my Astro Project:

import { defineConfig } from "astro/config";
import cloudflare from "@astrojs/cloudflare";
import sentry from "@sentry/astro";

export default defineConfig({
  output: "server",
  experimental: {
    actions: true,
  },
  adapter: cloudflare({}),
  integrations: [
    sentry({
      dsn: "https://18aba3b773c3ef1891e719e73a311ec4@o4505279164252160.ingest.us.sentry.io/4507712395214848",
      sourceMapsUploadOptions: {
        project: "pwa-astro",
        authToken: import.process.env.SENTRY_AUTH_TOKEN,
      },
    }),
  ],
});

But on build I receive this error:

11:16:47 [ERROR] [vite] x Build failed in 1.49s
[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "node:http" imported from "node_modules/@sentry/node/build/esm/integrations/spotlight.js". Consider disabling ssr.noExternal or remove the built-in dependency.

So I extendet my astro config:

  vite: {
    ssr: {
      external: ["node:http"]
    },
  },

But then I get the next error:

[commonjs--resolver] [plugin vite:resolve] Cannot bundle Node.js built-in "node:fs" imported from "node_modules/@sentry/node/build/esm/integrations/contextlines.js". Consider disabling ssr.noExternal or remove the built-in dependency.

Solution Brainstorm

Cloudflare provides a sentry plugin: https://developers.cloudflare.com/pages/functions/plugins/sentry/
Is it possible that to use this plugin to make the Sentry/Astro integration compatible with CF Pages?
Maybe releated to: #12620

Metadata

Metadata

Assignees

Labels

Package: astroIssues related to the Sentry Astro SDKPackage: cloudflareIssues related to the Sentry Cloudflare Workers SDK

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions