Skip to content

Commit ff591f3

Browse files
logaretmclaude
andcommitted
fix(nitro): Skip source map upload in nitro-prerender nested build
Nitro spawns a nested Nitro instance for prerendering with the user's `modules` array re-installed, which caused the Sentry module to run twice and upload source maps + create a release twice per build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9a575d4 commit ff591f3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/nitro/src/sourceMaps.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export function setupSourceMaps(nitro: Nitro, options?: SentryNitroOptions, sent
1313
return;
1414
}
1515

16+
// Nitro spawns a nested Nitro instance for prerendering with the user's `modules` re-installed.
17+
// Uploading here would double-upload source maps and create a duplicate release.
18+
if (nitro.options.preset === 'nitro-prerender') {
19+
return;
20+
}
21+
1622
// Respect user's explicit disable
1723
if (options?.sourcemaps?.disable === true) {
1824
return;

packages/nitro/test/sourceMaps.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,18 @@ describe('setupSourceMaps', () => {
274274
expect(hookFn).not.toHaveBeenCalled();
275275
});
276276

277+
it('does not register hook in nitro-prerender preset', () => {
278+
const hookFn = vi.fn();
279+
const nitro = {
280+
options: { dev: false, preset: 'nitro-prerender', output: { serverDir: '/output/server' } },
281+
hooks: { hook: hookFn },
282+
} as any;
283+
284+
setupSourceMaps(nitro);
285+
286+
expect(hookFn).not.toHaveBeenCalled();
287+
});
288+
277289
it('registers compiled hook in production mode', () => {
278290
const hookFn = vi.fn();
279291
const nitro = {

0 commit comments

Comments
 (0)