Skip to content

Commit 55c9b98

Browse files
committed
fix(astro): prevent sentry from externalized (#9994)
Fixes #9777
1 parent d833da7 commit 55c9b98

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/astro/src/integration/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
8080
options.debug && logger.info('Using default server init.');
8181
injectScript('page-ssr', buildServerSnippet(options || {}));
8282
}
83+
84+
// Prevent Sentry from being externalized for SSR.
85+
// Cloudflare like environments have Node.js APIs are available under `node:` prefix.
86+
// Ref: https://developers.cloudflare.com/workers/runtime-apis/nodejs/
87+
if (config?.adapter?.name.startsWith('@astro/cloudflare')) {
88+
updateConfig({
89+
vite: {
90+
ssr: {
91+
noExternal: ['@sentry/astro', '@sentry/node'],
92+
},
93+
},
94+
});
95+
}
8396
}
8497

8598
const isSSR = config && (config.output === 'server' || config.output === 'hybrid');

0 commit comments

Comments
 (0)