fix(tracing): mkdir tracesDir before live .stacks writes#40730
fix(tracing): mkdir tracesDir before live .stacks writes#40730Skn0tt wants to merge 1 commit intomicrosoft:mainfrom
Conversation
`localUtils.tracingStarted` returns a stacksId pointing at `<tracesDir>/<traceName>.stacks`, and `addStackToTracingNoReply` writes to that file directly via `fs.writeFile`. The trace recorder enqueues a recursive mkdir of `<tracesDir>/resources` through its own `SerializedFS` queue, but the two queues have no happens-before relationship — so when live tracing fires a stack write before the recorder's mkdir drains, the write fails with ENOENT. Surfaces as a flake on slower shards (observed on mcp-windows-latest-firefox via tests/mcp/tracing.spec.ts:54). Make the contract self-contained by precreating the directory in tracingStarted before any caller can write to it.
Test results for "MCP"9 failed 7022 passed, 1068 skipped Merge workflow run. |
Test results for "tests 1"4 flaky41692 passed, 850 skipped Merge workflow run. |
Fixes a race in live tracing.
localUtils.tracingStartedreturns a stacksId at<tracesDir>/<traceName>.stacks, andaddStackToTracingNoReplywrites to that file directly. The recorder’sTracingenqueues a recursive mkdir of<tracesDir>/resourcesthrough its ownSerializedFSqueue — separate from the per-session writer chain inlocalUtils, so there’s no happens-before guarantee between them.When the SerializedFS worker hasn’t drained the mkdir yet and a stack write fires (live mode + an action like
page.goto), the write fails with ENOENT.Surfaces as a flake on
mcp-windows-latest-firefoxviatests/mcp/tracing.spec.ts:54(browser_stop_tracingreturnsresult: undefinedbecause tracing.stop bubbled the ENOENT).Fix: precreate
path.dirname(traceStacksFile)intracingStarted, so the contract is self-contained for any caller.https://mspwblobreport.z1.web.core.windows.net/run-25561393525-1-d8c56b0253640b9f180ee09093c38892d31661d7/index.html#?testId=39a796cef0e6f5869c06-d52e545eb08e8dd5c09c7