[DevTools] Fix display of stack frames with anonymous sources (#34237)

This commit is contained in:
Sebastian "Sebbie" Silbermann 2025-08-20 17:31:42 +02:00 committed by GitHub
parent 0bc71e67ab
commit 03fda05d2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 9 deletions

View File

@ -52,8 +52,8 @@ function parseStackTraceFromChromeStack(
if (filename === '<anonymous>') { if (filename === '<anonymous>') {
filename = ''; filename = '';
} }
const line = +(parsed[3] || parsed[6]); const line = +(parsed[3] || parsed[6] || 0);
const col = +(parsed[4] || parsed[7]); const col = +(parsed[4] || parsed[7] || 0);
parsedFrames.push([name, filename, line, col, 0, 0, isAsync]); parsedFrames.push([name, filename, line, col, 0, 0, isAsync]);
} }
return parsedFrames; return parsedFrames;
@ -235,6 +235,7 @@ function collectStackTrace(
// at name (filename:0:0) // at name (filename:0:0)
// at filename:0:0 // at filename:0:0
// at async filename:0:0 // at async filename:0:0
// at Array.map (<anonymous>)
const chromeFrameRegExp = const chromeFrameRegExp =
/^ *at (?:(.+) \((?:(.+):(\d+):(\d+)|\<anonymous\>)\)|(?:async )?(.+):(\d+):(\d+)|\<anonymous\>)$/; /^ *at (?:(.+) \((?:(.+):(\d+):(\d+)|\<anonymous\>)\)|(?:async )?(.+):(\d+):(\d+)|\<anonymous\>)$/;

View File

@ -63,13 +63,18 @@ export function CallSiteView({
return ( return (
<div className={styles.CallSite}> <div className={styles.CallSite}>
{functionName || virtualFunctionName} {functionName || virtualFunctionName}
{' @ '} {url !== '' && (
<span <>
className={linkIsEnabled ? styles.Link : null} {' @ '}
onClick={viewSource} <span
title={url + ':' + line}> className={linkIsEnabled ? styles.Link : null}
{formatLocationForDisplay(url, line, column)} onClick={viewSource}
</span> title={url + ':' + line}>
{formatLocationForDisplay(url, line, column)}
</span>
</>
)}
<ElementBadges environmentName={environmentName} /> <ElementBadges environmentName={environmentName} />
</div> </div>
); );

View File

@ -40,5 +40,9 @@ export default function formatLocationForDisplay(
} }
} }
if (line === 0) {
return nameOnly;
}
return `${nameOnly}:${line}`; return `${nameOnly}:${line}`;
} }