[Feature]: Test runner captures and source-maps stacks that it never uses

未关闭
#44,334 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@microsoft-playwright-automation 已经在做这个了。

开始于 2026年11月24日。

  • #44338 来自 @microsoft-playwright-automation —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
30/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

Start in fixtureRunner.ts where _stepInfo.stack is set for built-in fixture steps, and in packages/isomorphic/manualPromise.ts at LongStandingScope._race(). Read closed PR #44326 for the already-tested implementation, then run the test-runner and manual-promise tests covering step metadata and close-error stacks. Done means built-in fixture steps carry stack: [], _race() reads .stack only when cloning a close error, and existing stack output stays unchanged.

由索引模型根据 Issue 内容生成。

描述

agent-triage-done
Problem

Two hot paths in the worker format stacks that nobody reads:

  1. Built-in fixture steps (page, context, request, and about 30 more) have no user location. In fixtureRunner.ts, _stepInfo.stack is undefined, so testInfo._addStep() captures and source-maps a full raw stack, then filters it to 0 frames. This happens about 60 times per test.
  2. LongStandingScope._race() in packages/isomorphic/manualPromise.ts reads new Error().stack on every call. The formatted stack is used only when the scope closes during the race.
Measurements

CPU profile of a 24-test suite, Apple Silicon, Chromium headless shell, 1 worker, median of 5 runs:

Now With both changes
Worker CPU time 995 ms 806 ms (−19%)
Proposed approach
  1. Give built-in fixture steps stack: []. User fixtures keep their registration location.
  2. In _race(), keep the Error and read .stack only when it clones a close error. V8 records the frames when the Error is constructed, so close messages stay the same.

One difference: built-in fixture steps no longer report user locations injected by a custom Error.prepareStackTrace formatter. With the default formatter, they never had a location.

Already implemented and tested in #44326, which was closed only to file this issue first. Both are small, low-risk performance fixes. Reopening #44326 is the fastest path; it is ready for review.

主要语言
TypeScript
星标
100k
派生
6.9k
平均合并
16 小时 18 分钟
30 天内合并 PR
281

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/playwright 的其他 Issue

查看 microsoft/playwright 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。