Skip to content

Commit 379adc7

Browse files
committed
Add warn message if no instrument file found
1 parent 3a48e1b commit 379adc7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/tanstackstart-react/src/vite/copyInstrumentationFile.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function makeCopyInstrumentationFilePlugin(): Plugin {
4949
);
5050
});
5151
}
52+
5253
},
5354

5455
async closeBundle() {
@@ -61,7 +62,13 @@ export function makeCopyInstrumentationFilePlugin(): Plugin {
6162
try {
6263
await fs.promises.access(instrumentationSource, fs.constants.F_OK);
6364
} catch {
64-
// No instrumentation file found — nothing to copy
65+
consoleSandbox(() => {
66+
// eslint-disable-next-line no-console
67+
console.warn(
68+
'[Sentry TanStack Start] No instrument.server.mjs file found in project root. ' +
69+
'The Sentry instrumentation file will not be copied to the build output.',
70+
);
71+
});
6572
return;
6673
}
6774

packages/tanstackstart-react/test/vite/copyInstrumentationFile.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('makeCopyInstrumentationFilePlugin()', () => {
196196
warnSpy.mockRestore();
197197
});
198198

199-
it('does nothing when instrumentation file does not exist', async () => {
199+
it('warns and does not copy when instrumentation file does not exist', async () => {
200200
const resolvedConfig = {
201201
root: '/project',
202202
plugins: [{ name: 'nitro' }],
@@ -217,10 +217,18 @@ describe('makeCopyInstrumentationFilePlugin()', () => {
217217

218218
vi.mocked(fs.promises.access).mockRejectedValueOnce(new Error('ENOENT'));
219219

220+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
221+
220222
await (plugin.closeBundle as AnyFunction)();
221223

222224
expect(fs.promises.access).toHaveBeenCalled();
223225
expect(fs.promises.copyFile).not.toHaveBeenCalled();
226+
expect(warnSpy).toHaveBeenCalledWith(
227+
'[Sentry TanStack Start] No instrument.server.mjs file found in project root. ' +
228+
'The Sentry instrumentation file will not be copied to the build output.',
229+
);
230+
231+
warnSpy.mockRestore();
224232
});
225233

226234
it('logs a warning when copy fails', async () => {

0 commit comments

Comments
 (0)