Skip to content

Commit b080063

Browse files
authored
[DevTools] Source Map Stack Traces such in await locations (facebook#34094)
Stacked on facebook#34093. Instead of using the original `ReactStackTrace` that has the call sites on the server, this parses the `Error` object which has the virtual call sites on the client. We'll need this technique for things stack traces suspending on the client anyway like `use()`. We can then use these callsites to source map in the front end. We currently don't source map function names but might be useful for this use case as well as getting original component names from prod. One thing this doesn't do yet is that it doesn't ignore list the stack traces on the client using the source map's ignore list setting. It's not super important since we expect to have already ignore listed on the server but this will become important for client stack traces like `use()`.
1 parent 66f09bd commit b080063

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/react-devtools-shared/src/__tests__/utils-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
401401
exports.f = f;
402402
function f() { }
403403
//# sourceMappingURL=`;
404-
const result = ['', 'http://test/a.mts', 1, 16];
404+
const result = ['', 'http://test/a.mts', 1, 17];
405405
const fs = {
406406
'http://test/a.mts': `export function f() {}`,
407407
'http://test/a.mjs.map': `{"version":3,"file":"a.mjs","sourceRoot":"","sources":["a.mts"],"names":[],"mappings":";;AAAA,cAAsB;AAAtB,SAAgB,CAAC,KAAI,CAAC"}`,

packages/react-devtools-shared/src/symbolicateSource.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ export async function symbolicateSource(
8282
const {
8383
sourceURL: possiblyURL,
8484
line,
85-
column,
85+
column: columnZeroBased,
8686
} = consumer.originalPositionFor({
8787
lineNumber, // 1-based
8888
columnNumber, // 1-based
8989
});
9090

91+
const column = columnZeroBased + 1;
92+
9193
if (possiblyURL === null) {
9294
return null;
9395
}

0 commit comments

Comments
 (0)