Skip to content

Commit f0325bd

Browse files
logaretmclaude
andcommitted
fix(browser): Add MAX_PLAUSIBLE_INP_DURATION check to streamed INP span path
The standalone INP handler filters out unrealistically long INP values (>60s) but the streamed span path was missing this sanity check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 45f3698 commit f0325bd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/browser-utils/src/metrics/webVitalSpans.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import type { InstrumentationHandlerCallback } from './instrument';
2222
import { addClsInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler } from './instrument';
2323
import { listenForWebVitalReportEvents, msToSec, supportsWebVital } from './utils';
2424

25+
// Maximum plausible INP duration in seconds (matches standalone INP handler)
26+
const MAX_PLAUSIBLE_INP_DURATION = 60;
27+
2528
interface WebVitalSpanOptions {
2629
name: string;
2730
op: string;
@@ -215,6 +218,11 @@ export function trackInpAsSpan(_client: Client): void {
215218
return;
216219
}
217220

221+
// Guard against unrealistically long INP values (matching standalone INP handler)
222+
if (msToSec(metric.value) > MAX_PLAUSIBLE_INP_DURATION) {
223+
return;
224+
}
225+
218226
const entry = metric.entries.find(e => e.duration === metric.value && INP_ENTRY_MAP[e.name]);
219227

220228
if (!entry) {

0 commit comments

Comments
 (0)