Browse Source

test(subprocess): measure the pipe-drain settle from before the pid-file handoff

Huanqi Cao 1 month ago
parent
commit
13d859a619
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/subprocess/subprocess-local/tests/spawn.spec.ts

+ 4 - 1
packages/subprocess/subprocess-local/tests/spawn.spec.ts

@@ -857,8 +857,11 @@ describe('coverage seams', () => {
       ...spec('unused', { graceMs: 100 }),
       argv: [process.execPath, '-e', childScript],
     })
-    const helper = await waitForPidFile(pidFile)
+    // The drain timer starts when the child's stdio closes, which can precede
+    // the pid file becoming visible; measure from before that wait so the
+    // lower bound cannot be eroded by the pid-file handoff.
     const started = Date.now()
+    const helper = await waitForPidFile(pidFile)
     const outcome = await running.done
     expect(outcome.exitCode).toBe(0)
     expect(Date.now() - started).toBeGreaterThanOrEqual(90)