The page stops recursing when a tap ends long after its answer (#378)
endTap reported the tap before clearing it; report's traceparent starts a new trace when the last is over a minute old, and newTrace ends the open tap again, so hiding the page (switching apps on the phone) a minute after using it recursed until the stack ran out. Timings are never throttled, so nothing broke the loop. Introduced in #376. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,9 +109,12 @@ function spanText(secs: number){
|
||||
let traceId='', traceAt=0, rootId='', rootAt=0, rootKind='', answeredAt=0;
|
||||
const hex=(n: number)=>Array.from(crypto.getRandomValues(new Uint8Array(n)),b=>b.toString(16).padStart(2,'0')).join('');
|
||||
function endTap(){
|
||||
if(rootKind && answeredAt>rootAt)
|
||||
report('tap',{trace:traceId,span:rootId,start:rootAt,ms:Math.min(answeredAt-rootAt,60_000),msg:rootKind});
|
||||
const kind=rootKind;
|
||||
// Cleared first: report's traceparent can start a new trace, whose newTrace calls endTap again,
|
||||
// and with the tap still open that recursed until the stack ran out (#378).
|
||||
rootKind='';
|
||||
if(kind && answeredAt>rootAt)
|
||||
report('tap',{trace:traceId,span:rootId,start:rootAt,ms:Math.min(answeredAt-rootAt,60_000),msg:kind});
|
||||
}
|
||||
function newTrace(kind: string){
|
||||
endTap();
|
||||
|
||||
Reference in New Issue
Block a user