Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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\>)$/;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ export function CallSiteView({
return (
<div className={styles.CallSite}>
{functionName || virtualFunctionName}
{' @ '}
<span
className={linkIsEnabled ? styles.Link : null}
onClick={viewSource}
title={url + ':' + line}>
{formatLocationForDisplay(url, line, column)}
</span>
{url !== '' && (
<>
{' @ '}
<span
className={linkIsEnabled ? styles.Link : null}
onClick={viewSource}
title={url + ':' + line}>
{formatLocationForDisplay(url, line, column)}
</span>
</>
)}
Comment on lines +66 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about displaying something like Array.map @ native? This is aligned with how Chrome displays V8's stacks.

I am not aware of other potential cases where url could be an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually, I think we should extend ReactStackTrace to have boolean isNative instead. Because we already handle it here:

} else if (callSite.isNative()) {
// $FlowFixMe[prop-missing]
const isAsync = callSite.isAsync();
result.push([name, '', 0, 0, 0, 0, isAsync]);

And if its native, we should add @ native suffix, else if url is absent, then just don't display it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can do that in a follow-up. We'd still want something for anonymous sources. Especially for the cases where we don't have access to structured stack traces.

Chrome isn't consistent with displaying the stacks anyway so it doesn't seem terribly important to be perfectly aligned. The @ format is really just in tracing I think. Printing .stack doesn't use that formatting and use at Array.map (<anonymous>) instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isNative() is also false for Array.prototype.map for me:

let error

const awaitedFlags = ['one'].map( (param) => {
    error = new Error()
    return 'a'
}
)

Error.prepareStackTrace = (error, structuredStackTrace) => {
    for (const frame of structuredStackTrace) {
        console.log(frame.toString(), frame.isNative())
    }
    return ''
}

error.stack


<ElementBadges environmentName={environmentName} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ export default function formatLocationForDisplay(
}
}

if (line === 0) {
return nameOnly;
}
Comment on lines +43 to +45
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly a drive-by. 0 is the bottom value when we have no line number so we should omit it entirely.


return `${nameOnly}:${line}`;
}
Loading