chore: print full stacks when PWDEBUGIMPL is set (#16113)

For debugging purposes, especially on the client's computers.
This commit is contained in:
Dmitry Gozman 2022-08-01 13:44:59 -07:00 committed by GitHub
parent 97bb0f3d46
commit 5481e25015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -83,9 +83,9 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
const { frame, fileName } = parseStackTraceLine(line);
if (!frame || !frame.file || !fileName)
return null;
if (isInternalFileName(frame.file, frame.function))
if (!process.env.PWDEBUGIMPL && isInternalFileName(frame.file, frame.function))
return null;
if (isTesting && fileName.includes(COVERAGE_PATH))
if (!process.env.PWDEBUGIMPL && isTesting && fileName.includes(COVERAGE_PATH))
return null;
const inCore = fileName.startsWith(CORE_LIB) || fileName.startsWith(CORE_SRC);
const parsed: ParsedFrame = {
@ -109,7 +109,8 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
if (parsedFrames[i].inCore && !parsedFrames[i + 1].inCore) {
const frame = parsedFrames[i].frame;
apiName = normalizeAPIName(frame.function);
parsedFrames = parsedFrames.slice(i + 1);
if (!process.env.PWDEBUGIMPL)
parsedFrames = parsedFrames.slice(i + 1);
break;
}
}
@ -125,6 +126,8 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
// Hide all test runner and library frames in the user stack (event handlers produce them).
parsedFrames = parsedFrames.filter((f, i) => {
if (process.env.PWDEBUGIMPL)
return true;
if (f.frame.file.startsWith(TEST_DIR_SRC) || f.frame.file.startsWith(TEST_DIR_LIB))
return false;
if (i && f.frame.file.startsWith(CORE_DIR))

View File

@ -35,6 +35,9 @@ const EXPECT_PATH_IMPL = require.resolve('./expectBundleImpl');
const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '..');
function filterStackTrace(e: Error) {
if (process.env.PWDEBUGIMPL)
return;
// This method filters internal stack frames using Error.prepareStackTrace
// hook. Read more about the hook: https://v8.dev/docs/stack-trace-api
//