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
9 changes: 7 additions & 2 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,8 @@ describe('ReactFlight', () => {
// third-party RSC frame
// Ideally this would be a real frame produced by React not a mocked one.
' at ThirdParty (rsc://React/ThirdParty/file:///code/%5Broot%2520of%2520the%2520server%5D.js?42:1:1)',
// We'll later filter this out based on line/column in `filterStackFrame`.
' at ThirdPartyModule (file:///file-with-index-source-map.js:52656:16374)',
// host component in parent stack
' at div (<anonymous>)',
...originalStackLines.slice(2),
Expand Down Expand Up @@ -1357,7 +1359,10 @@ describe('ReactFlight', () => {
}
return `digest(${String(x)})`;
},
filterStackFrame(filename, functionName) {
filterStackFrame(filename, functionName, lineNumber, columnNumber) {
if (lineNumber === 52656 && columnNumber === 16374) {
return false;
}
if (!filename) {
// Allow anonymous
return functionName === 'div';
Expand Down Expand Up @@ -3682,7 +3687,7 @@ describe('ReactFlight', () => {
onError(x) {
return `digest("${x.message}")`;
},
filterStackFrame(url, functionName) {
filterStackFrame(url, functionName, lineNumber, columnNumber) {
return functionName !== 'intermediate';
},
},
Expand Down
24 changes: 20 additions & 4 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ function findCalledFunctionNameFromStackTrace(
const callsite = stack[i];
const functionName = callsite[0];
const url = devirtualizeURL(callsite[1]);
const lineNumber = callsite[2];
const columnNumber = callsite[3];
if (functionName === 'new Promise') {
// Ignore Promise constructors.
} else if (url === 'node:internal/async_hooks') {
// Ignore the stack frames from the async hooks themselves.
} else if (filterStackFrame(url, functionName)) {
} else if (filterStackFrame(url, functionName, lineNumber, columnNumber)) {
if (bestMatch === '') {
// If we had no good stack frames for internal calls, just use the last
// first party function name.
Expand Down Expand Up @@ -236,7 +238,9 @@ function filterStackTrace(
const callsite = stack[i];
const functionName = callsite[0];
const url = devirtualizeURL(callsite[1]);
if (filterStackFrame(url, functionName)) {
const lineNumber = callsite[2];
const columnNumber = callsite[3];
if (filterStackFrame(url, functionName, lineNumber, columnNumber)) {
// Use a clone because the Flight protocol isn't yet resilient to deduping
// objects in the debug info. TODO: Support deduping stacks.
const clone: ReactCallSite = (callsite.slice(0): any);
Expand Down Expand Up @@ -466,7 +470,12 @@ export type Request = {
// DEV-only
completedDebugChunks: Array<Chunk | BinaryChunk>,
environmentName: () => string,
filterStackFrame: (url: string, functionName: string) => boolean,
filterStackFrame: (
url: string,
functionName: string,
lineNumber: number,
columnNumber: number,
) => boolean,
didWarnForKey: null | WeakSet<ReactComponentInfo>,
writtenDebugObjects: WeakMap<Reference, string>,
deferredDebugObjects: null | DeferredDebugStore,
Expand Down Expand Up @@ -2180,7 +2189,14 @@ function visitAsyncNode(
const callsite = fullStack[firstFrame];
const functionName = callsite[0];
const url = devirtualizeURL(callsite[1]);
isAwaitInUserspace = filterStackFrame(url, functionName);
const lineNumber = callsite[2];
const columnNumber = callsite[3];
isAwaitInUserspace = filterStackFrame(
url,
functionName,
lineNumber,
columnNumber,
);
}
if (!isAwaitInUserspace) {
// If this await was fully filtered out, then it was inside third party code
Expand Down
Loading