From a4593a2af68fe3ecfb5ee77cc4016f23e63bcaf4 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 30 Oct 2024 16:55:16 +0100 Subject: [PATCH 1/4] silently fail maybeInstrument --- packages/utils/src/instrument/handlers.ts | 8 ++++++-- packages/utils/test/instrument.test.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 packages/utils/test/instrument.test.ts diff --git a/packages/utils/src/instrument/handlers.ts b/packages/utils/src/instrument/handlers.ts index b22f01318b0a..d76ec2fe3201 100644 --- a/packages/utils/src/instrument/handlers.ts +++ b/packages/utils/src/instrument/handlers.ts @@ -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(); + instrumented[type] = true; + } catch (e) { + DEBUG_BUILD && logger.error('Error while instrumenting', e); + } } } diff --git a/packages/utils/test/instrument.test.ts b/packages/utils/test/instrument.test.ts new file mode 100644 index 000000000000..440a19121a1a --- /dev/null +++ b/packages/utils/test/instrument.test.ts @@ -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); + }); +}); From 6cc714a1c14e8bf5db6da9623dbaedb2ae8894b4 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 31 Oct 2024 09:42:26 +0100 Subject: [PATCH 2/4] Update packages/utils/src/instrument/handlers.ts Co-authored-by: Francesco Novy --- packages/utils/src/instrument/handlers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/instrument/handlers.ts b/packages/utils/src/instrument/handlers.ts index d76ec2fe3201..7ab0ce33131b 100644 --- a/packages/utils/src/instrument/handlers.ts +++ b/packages/utils/src/instrument/handlers.ts @@ -41,7 +41,7 @@ export function maybeInstrument(type: InstrumentHandlerType, instrumentFn: () => instrumentFn(); instrumented[type] = true; } catch (e) { - DEBUG_BUILD && logger.error('Error while instrumenting', e); + DEBUG_BUILD && logger.error(`Error while instrumenting ${type}`, e); } } } From b2a5d85295db847c8504b33910d8ed39a404ad7c Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 31 Oct 2024 16:01:18 +0100 Subject: [PATCH 3/4] always set instrumented flag --- packages/utils/src/instrument/handlers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/instrument/handlers.ts b/packages/utils/src/instrument/handlers.ts index 7ab0ce33131b..672c819e17a6 100644 --- a/packages/utils/src/instrument/handlers.ts +++ b/packages/utils/src/instrument/handlers.ts @@ -37,9 +37,9 @@ 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]) { + instrumented[type] = true; try { instrumentFn(); - instrumented[type] = true; } catch (e) { DEBUG_BUILD && logger.error(`Error while instrumenting ${type}`, e); } From 604cf64b393ccb785985f4072e846301a038c444 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 4 Nov 2024 09:53:44 +0100 Subject: [PATCH 4/4] bump next size limit --- .size-limit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.size-limit.js b/.size-limit.js index 75545fd89194..cd2a3630ef5c 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -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) {