Record what spawned node processes import and read, so a test that runs a script through child_process reruns when that script or its imports change #11
<!-- devin-pr-monitoring-controls -->
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
<!-- codesmith:proof -->
<picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-3x.png" align="top" width="22" height="22"></picture> Spawned script edits rerun the test <img src="https://backend.blacksmith.sh/api/proof-report-pixel.gif?installation_model_id=2&pr_number=11&published_at=1793994725&repository=useblacksmith%2Fvitest&run_id=01a1b269-1eb2-70b7-94d4-afd11fe2e379&signature=1add1e9b3d4ee9f61ff330288d759b8aae12b23e0291b2271a55e74cee8eabcd" width="1" height="1" alt="">
Editing the spawned script, its import, or the file it reads reruns all three spawning tests (spawnSync, promisify(exec), promisify(execFile)) and not the unrelated one; before, each edit ran nothing.
<sub>Merge-base</sub>
<a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e#evidence=01a1b256-f00a-7379-862c-839e9e0eb322/case:c1:0"><img src="https://backend.blacksmith.sh/api/attachments/01a1b269-d17e-7222-9de7-9a91a86b929f.e7f2262b1d07839f" alt="Edits run nothing" width="680"></a>
<sub>This PR <code>c5f909b6</code></sub>
<a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e#evidence=01a1b256-f00a-7379-862c-839e9e0eb322/case:c1:1"><img src="https://backend.blacksmith.sh/api/attachments/01a1b269-d296-72c5-b400-f17520e80ecf.67527c57c4bd3e02" alt="Edits rerun 3 of 4" width="680"></a>
Also checked · 4 match
<picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Non-node child: command-line files<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> NODE\_OPTIONS: undefined stays bare<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> tsx-preloaded child fs imports<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Promisified exec keeps .child
<sub>Proof on <code>c5f909b6</code> (from <code>9dc961a9</code>) · Did Proof get it right? <a href="https://app.blacksmith.sh/useblacksmith/sessions/01a1b256-e3a8-735c-87a0-a570f37b42b5?autoLogin=true&pane=proof-report%3A01a1b256-f00a-7379-862c-839e9e0eb322&focus=proof&ref=proof_github_rating&rate=up&run=01a1b269-1eb2-70b7-94d4-afd11fe2e379">Yes</a> · <a href="https://app.blacksmith.sh/useblacksmith/sessions/01a1b256-e3a8-735c-87a0-a570f37b42b5?autoLogin=true&pane=proof-report%3A01a1b256-f00a-7379-862c-839e9e0eb322&focus=proof&ref=proof_github_rating&rate=down&run=01a1b269-1eb2-70b7-94d4-afd11fe2e379">No</a></sub>
<!-- codesmith:proof:staging -->
<picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-3x.png" align="top" width="22" height="22"></picture> Script import edit reruns spawning test <img src="https://stagingbackend.blacksmith.sh/api/proof-report-pixel.gif?installation_model_id=8&pr_number=11&published_at=1793994745&repository=useblacksmith%2Fvitest&run_id=01a1b269-28d8-700e-901c-21745f38f0f8&signature=2f4bb6d5a5f41dcc3182b78e387e1e767192fc38e75af9023d7a77d564aaf7fb" width="1" height="1" alt="">
After a breaking edit to the module the spawned script imports, the affected run still skipped every test before and reran only the spawning test (which failed) after.
<sub>Merge-base</sub>
<a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b#evidence=01a1b256-f5d4-7014-ad4b-cf36883f5e96/case:c1:0"><img src="https://stagingbackend.blacksmith.sh/api/attachments/01a1b269-ba3f-7367-b37a-57db37ab1f32.dff73c8f20c8e533" alt="Import edit skipped" width="659"></a>
<sub>This PR <code>c5f909b6</code></sub>
<a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b#evidence=01a1b256-f5d4-7014-ad4b-cf36883f5e96/case:c1:1"><img src="https://stagingbackend.blacksmith.sh/api/attachments/01a1b269-ba63-70d8-9a67-f38240a8e7a2.17621c933f28b9a2" alt="Spawning test reruns" width="659"></a>
Also checked · 6 match
<picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> promisify\(exec\) child records its reads<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Grandchild imports are recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> NODE\_OPTIONS: undefined child stays bare<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> promisify\(execFile\) child is recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Preloaded child's named fs imports recorded<br><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-dark-inline.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline.svg"><img alt="Matches" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-claim-matches-blue-light-inline-3x.png" align="absmiddle" width="16" height="17"></picture> Promisified exec keeps child handle
<sub>Proof on <code>c5f909b6</code> (from <code>9dc961a9</code>) · not run: Blacksmith Actions cache backend (not needed) · Did Proof get it right? <a href="https://staging.blacksmith.sh/useblacksmith/sessions/01a1b256-e486-717b-951a-63f194333258?autoLogin=true&pane=proof-report%3A01a1b256-f5d4-7014-ad4b-cf36883f5e96&focus=proof&ref=proof_github_rating&rate=up&run=01a1b269-28d8-700e-901c-21745f38f0f8">Yes</a> · <a href="https://staging.blacksmith.sh/useblacksmith/sessions/01a1b256-e486-717b-951a-63f194333258?autoLogin=true&pane=proof-report%3A01a1b256-f5d4-7014-ad4b-cf36883f5e96&focus=proof&ref=proof_github_rating&rate=down&run=01a1b269-28d8-700e-901c-21745f38f0f8">No</a></sub>
View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss
<!-- BUGBOT_REVIEW -->
<!-- BUGBOT_REVIEW_STALE -->
Stale Bugbot comment from a previous run.
Promisify bypasses spawn instrumentation
Medium Severity
<!-- DESCRIPTION START -->copyProperties copies promisify.custom from the original exec/execFile, and that custom function calls the unwrapped original. promisify(execFile) therefore never injects the recorder, so the child's modules and reads are not added as dependencies.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 677a3078-acb9-4343-bf2f-932ad05a8a1a -->
<!-- LOCATIONS START
src/record-reads.ts#L197-L200
src/record-reads.ts#L171-L197
LOCATIONS END -->
<details>
<summary>Additional Locations (1)</summary>
src/record-reads.ts#L171-L197</details>
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIxOWRhMjBhLWFiZDQtNGFkMS05NmJmLWIzYjcxNDcyNmZjYiIsImVuY3J5cHRpb25LZXkiOiItZ2d4U1hNLW9fOWQ2MWpuazFaenZ4MjZzQnkyalZVYVdZdVJKUFJ4cmpjIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIxOWRhMjBhLWFiZDQtNGFkMS05NmJmLWIzYjcxNDcyNmZjYiIsImVuY3J5cHRpb25LZXkiOiItZ2d4U1hNLW9fOWQ2MWpuazFaenZ4MjZzQnkyalZVYVdZdVJKUFJ4cmpjIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiJjZjRjMzhmMDZmZGI5ZDEwZjljNmJiM2Q3OGQ3ZDgxZjBiNzg4ZWRjIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit cf4c38f06fdb9d10f9c6bb3d78d7d81f0b788edc. Configure here.</sup>
Child recorder misses ESM fs reads
Medium Severity
<!-- DESCRIPTION START -->
The recorder --import is appended onto existing NODE_OPTIONS, so preloaders such as tsx run first and can bind node:fs ESM exports before wrapping. record-child also never calls syncBuiltinESMExports, so a child's import { readFileSync } from 'node:fs' can skip the wrapper and drop those reads.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: b63971ee-1ad1-4782-a2db-ed08818cad16 -->
<!-- LOCATIONS START
src/record-reads.ts#L131-L137
src/record-child.ts#L25-L26
LOCATIONS END -->
<details>
<summary>Additional Locations (1)</summary>
src/record-child.ts#L25-L26</details>
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMzMWRhM2UwLWE4ZWEtNGYzOC1iZmYyLWI5OTg0ZDY3ZWZhZCIsImVuY3J5cHRpb25LZXkiOiJOSDRmb1p5Z1lGNHF4SWw4T1Rsbl84Y3JVQXN5eG5JUTZBb01JcllqMndrIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMzMWRhM2UwLWE4ZWEtNGYzOC1iZmYyLWI5OTg0ZDY3ZWZhZCIsImVuY3J5cHRpb25LZXkiOiJOSDRmb1p5Z1lGNHF4SWw4T1Rsbl84Y3JVQXN5eG5JUTZBb01JcllqMndrIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiJjZjRjMzhmMDZmZGI5ZDEwZjljNmJiM2Q3OGQ3ZDgxZjBiNzg4ZWRjIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit cf4c38f06fdb9d10f9c6bb3d78d7d81f0b788edc. Configure here.</sup>
Right for execFile: Node's exec goes through module.exports.execFile (the wrapped one), but execFile[promisify.custom] calls the original directly. 9dc961a gives the wrapped exec/execFile their own promisify.custom that calls the wrapper with a callback (same { stdout, stderr } resolution and error augmentation as Node's). The fixture child-async.test.ts now uses promisify(execFile), and its edits rerun the test.
Agreed: a preloader ahead of ours can have materialized the node:fs ESM namespace already. 9dc961a calls syncBuiltinESMExports() in record-child right after wrapping, the same way record-reads does in the test process, so named imports in the child see the wrappers regardless of NODE_OPTIONS order. The ordering itself is left as is, since appending keeps the user's loaders (tsx) resolving first.
Promisify wrapper drops child handle
Medium Severity
<!-- DESCRIPTION START -->
The replacement promisify.custom for exec and execFile never sets child on the returned promise. Node attaches the ChildProcess there, and @types/node types it as PromiseWithChild, so tests that use the handle after promisify(execFile) get undefined and throw.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: d728abbf-6ad8-41c8-bb07-26c3c7e5bb99 -->
<!-- LOCATIONS START
src/record-reads.ts#L200-L213
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVjNGU5YmYxLTkxN2UtNDdlMS04YmFkLTY4NTMzZmE3NDQ1NCIsImVuY3J5cHRpb25LZXkiOiJ3MDVCdmtYMzZ3ZWppRXNqU2F5R2U4bEtiR1RaQnpXQnJhMjVRcWxGWC1zIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjVjNGU5YmYxLTkxN2UtNDdlMS04YmFkLTY4NTMzZmE3NDQ1NCIsImVuY3J5cHRpb25LZXkiOiJ3MDVCdmtYMzZ3ZWppRXNqU2F5R2U4bEtiR1RaQnpXQnJhMjVRcWxGWC1zIiwiYnJhbmNoIjoiZGV2aW4vMTc5Mzk5MjUxMy1yZWNvcmQtY2hpbGQtcHJvY2Vzc2VzIiwicmVwb093bmVyIjoidXNlYmxhY2tzbWl0aCIsInJlcG9OYW1lIjoidml0ZXN0IiwicHJOdW1iZXIiOjExLCJjb21taXRTaGEiOiI5ZGM5NjFhOTM1Yjk3MjAzY2YwM2NkNzg5OTNjMjVlNjAwNDVlYjAzIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 9dc961a935b97203cf03cd78993c25e60045eb03. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTowZmMzMGY1Yy0zMzQ4LTQzZDEtODdiZS1kMWViOWE0NDUwYjQiLCJlbmNyeXB0aW9uS2V5IjoiTDZJTFlZY0k1b0pXZk41V0g0MHdVSGxPQkFRSjlaREhLeXlDeGJPWXQ3USIsImJyYW5jaCI6ImRldmluLzE3OTM5OTI1MTMtcmVjb3JkLWNoaWxkLXByb2Nlc3NlcyIsInJlcG9Pd25lciI6InVzZWJsYWNrc21pdGgiLCJyZXBvTmFtZSI6InZpdGVzdCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by Cursor Bugbot for commit 9dc961a935b97203cf03cd78993c25e60045eb03. Configure here.</sup>
Good catch. c5f909b sets child on the returned promise the way Node does, and the fixture now asserts pending.child.pid before awaiting.
cursor[bot]
max-blacksmith
Summary
A test that exercises a script by spawning it (
spawnSync(process.execPath, ['scripts/bench.ts']),exec('node dist/cli.js ...')) had no recorded dependency on the script or anything it imports or reads, so the affected selection skipped it after a change to that script. On a large monorepo replay this was the one real miss against the repo's own planner: 22 of 1,781 test files in one project spawn a repo script by path.Record the child's modules and reads with a preloaded recorder
record-reads.ts(already the first setup file of every test) now also wrapschild_process.spawn/exec/execFile/forkand their*Syncforms. Each call getsrecord-child.tsruns in the child before its script: it wrapsnode:fsreads (samewrapReadsas the test process, moved tofs-recorder.ts), records everyfile:resolution throughmodule.registerHooks(ESM and CJS, including through loaders such as tsx), addsprocess.argv[1]andrequire.cache, and appends the set to the record file onexit. Grandchildren inherit the environment and append to the same file. When the child exits (sync: after the call returns; async: on'exit'/'error'), the test process reads the file and adds each path, resolved against the child'scwd, to__vitest_worker__.dependencies, where vitest picks them up like any other dependency of the test file.node_modulespaths are dropped as before.Independent of the child's runtime, the command and every argument that names an existing file are recorded at spawn time, so a shell script or binary still ties the test to the file it was given.
Keep deliberately bare children bare
A child spawned with
env: { ...process.env, NODE_OPTIONS: undefined }gets no recorder (only its command line is recorded): that pattern means the test wants to observe a child without node options, and the recorder's exit listener would show up in it.Other changes
copyProperties), sopromisify(exec)still findspromisify.custom.tsconfig.build.jsonsetsrewriteRelativeImportExtensions:record-child.tsimports./fs-recorder.tsby its real extension because node loads it directly (type-stripped) when the plugin runs from source, andtscrewrites it to.jsindist/.child.test.ts(spawnSync) andchild-async.test.ts(promisify(exec)) runsrc/scripts/child-script.mjs, which importschild-lib.mjsand readsfixtures/child/data.txt; editing any of the three reruns exactly those two tests.globalSetup, non-node programs and build outputs run in place of their sources still needdependencies.Link to Devin session: https://app.devin.ai/sessions/c7713a84ae564478a4c99c97d618fd0c
Open in Devin Desktop: https://app.devin.ai/desktop/session/c7713a84ae564478a4c99c97d618fd0c?variant=devin
Requested by: @max-blacksmith
<!-- codesmith:footer:staging -->
---
<a href="https://stagingbackend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f5d4-7014-ad4b-cf36883f5e96&signature=90904f39e8974a6b429c466215ab8ba7cbbd92f1f845bd05111f6f67bba3187b"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-light.svg"><img alt="View full Proof" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark-3x.png" width="131" height="28"></picture></a>
<sup><a href="https://staging.blacksmith.sh/useblacksmith/codesmith/vitest/pr/11?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. (Staging)</sup>
<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer:staging -->
<!-- codesmith:footer -->
---
<a href="https://backend.blacksmith.sh/track/proof-report?proof_session_id=01a1b256-f00a-7379-862c-839e9e0eb322&signature=6f876c5d464eb4ae24c66e9d9ddbc07ec20ce1dfaf709c978ea0baf3e5f9c34e"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-light.svg"><img alt="View full Proof" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-state-validated-dark-3x.png" width="131" height="28"></picture></a>
<sup><a href="https://app.blacksmith.sh/useblacksmith/codesmith/vitest/pr/11?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>
<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->