From 3cbe6bf53e00b23dd4471f0b62adb8ae414efee2 Mon Sep 17 00:00:00 2001 From: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:48:57 +0100 Subject: [PATCH] fix(solidstart): Do not copy release-injection map file (#15302) fixes https://github.com/getsentry/sentry-javascript/issues/15291 --- .../solidstart/src/config/addInstrumentation.ts | 4 +++- .../test/config/addInstrumentation.test.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/solidstart/src/config/addInstrumentation.ts b/packages/solidstart/src/config/addInstrumentation.ts index 74b72a12b4de..22494710a97c 100644 --- a/packages/solidstart/src/config/addInstrumentation.ts +++ b/packages/solidstart/src/config/addInstrumentation.ts @@ -45,7 +45,9 @@ export async function addInstrumentationFileToBuild(nitro: Nitro): Promise try { const ssrAssetsPath = path.resolve(buildDir, 'build', 'ssr', 'assets'); const assetsBuildDir = await fs.promises.readdir(ssrAssetsPath); - const releaseInjectionFile = assetsBuildDir.find(file => file.startsWith('_sentry-release-injection-file-')); + const releaseInjectionFile = assetsBuildDir.find(file => + /^_sentry-release-injection-file-.*\.(js|mjs)$/.test(file), + ); if (releaseInjectionFile) { const releaseSource = path.resolve(ssrAssetsPath, releaseInjectionFile); diff --git a/packages/solidstart/test/config/addInstrumentation.test.ts b/packages/solidstart/test/config/addInstrumentation.test.ts index 012bca76c9ca..1a71c8dbdd23 100644 --- a/packages/solidstart/test/config/addInstrumentation.test.ts +++ b/packages/solidstart/test/config/addInstrumentation.test.ts @@ -126,6 +126,23 @@ describe('addInstrumentationFileToBuild()', () => { expect(fsMkdirMock).not.toHaveBeenCalled(); }); + it('does not copy release injection file source map file', async () => { + fsExistsSyncMock.mockReturnValue(true); + fsReaddirMock.mockResolvedValueOnce(['_sentry-release-injection-file-test.js.map']); + fsCopyFileMock.mockResolvedValueOnce(true); + await addInstrumentationFileToBuild(nitroOptions); + + await callNitroCloseHook(); + + expect(fsCopyFileMock).not.toHaveBeenCalledWith( + '/path/to/buildDir/build/ssr/assets/_sentry-release-injection-file-test.js.map', + '/path/to/serverDir/assets/_sentry-release-injection-file-test.js.map', + ); + expect(consoleLogSpy).not.toHaveBeenCalledWith( + '[Sentry SolidStart withSentry] Successfully created /path/to/serverDir/assets/_sentry-release-injection-file-test.js.map.', + ); + }); + it('copies release injection file if available', async () => { fsExistsSyncMock.mockReturnValue(true); fsReaddirMock.mockResolvedValueOnce(['_sentry-release-injection-file-test.js']);