Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ module.exports = [
import: createImport('init'),
ignore: ['next/router', 'next/constants'],
gzip: true,
limit: '39.1 KB',
limit: '40 KB',
},
// SvelteKit SDK (ESM)
{
Expand Down
6 changes: 5 additions & 1 deletion packages/utils/src/instrument/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ export function resetInstrumentationHandlers(): void {
/** Maybe run an instrumentation function, unless it was already called. */
export function maybeInstrument(type: InstrumentHandlerType, instrumentFn: () => void): void {
if (!instrumented[type]) {
instrumentFn();
instrumented[type] = true;
try {
instrumentFn();
} catch (e) {
DEBUG_BUILD && logger.error(`Error while instrumenting ${type}`, e);
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions packages/utils/test/instrument.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { maybeInstrument } from '../src';

describe('maybeInstrument', () => {
test('does not throw when instrumenting fails', () => {
maybeInstrument('xhr', () => {
throw new Error('test');
});
});

test('does not throw when instrumenting fn is not a function', () => {
maybeInstrument('xhr', undefined as any);
});
});
Loading