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

View File

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

View File

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