Repository navigation
fix(runner): isolate worker fixture instances across extend() overrides (ENG-1400) - #2554
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.25.0 · 1m 4s · web · run artifacts |
Docs previewBuilt from 812a557: https://e2e-inc-docs-pr-2554.vercel.app/docs Changed pages: |
🟢 e2e web agent: 34 passed36 agent steps · 26 replayed from cache · 26 model calls · 134.3k tokens (94% cached) · $0.0056 All 34 tests in 5 files
Tested by e2e 0.25.0 · 1m 40s · web · run artifacts |
|
Found 1 test failure on Blacksmith runners: Failure
|
🟢 e2e android agent: 20 passed24 agent steps · 15 replayed from cache · 50 model calls · 379.5k tokens (84% cached) · $0.0237 All 20 tests in 1 file
Tested by e2e 0.25.0 · 7m 3s · android-emulator · run artifacts |
🟢 e2e ios: 67 passed, 1 skippedAll 68 tests in 8 files
Tested by e2e 0.25.0 · 8m 1s · ios-simulator · run artifacts |
🟢 e2e ios agent: 21 passed, 1 skipped25 agent steps · 12 replayed from cache · 54 model calls · 376.4k tokens (80% cached) · $0.0271 All 22 tests in 1 file
Tested by e2e 0.25.0 · 8m 18s · ios-simulator · run artifacts |
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (AI triage pass), not yet read by a maintainer.
Reviewed ee3ed9d00. Root-cause fix: the worker pool now keys a worker fixture by its identity plus the pool instances of the worker fixtures it names, so test.extend({ account }) gets its own client while chains that share every dependency still share one instance.
Verified:
- Bug is real on main: with
fixture-pool.tsreverted to main (rebuilt), the new integration test fails (customer clientexpectedpassed, gotfailed) and all 3 new unit tests fail. With the PR, 40/40 unit and 7/7 integration pass. - Keying by the
acquirepromise (not definition, not value) is what makes the transitive (client -> link -> account) and pass-through override cases work, and both have a unit test that fails without it. - Module re-evaluation still reuses instances: the dependency's promise comes back from the same
identityentry, so the dependent's inputs match again. - Built-ins stay out of the key (fixture-pool.ts:352-356), which is correct because the pool is per worker and target.
Should fix
- fixture-pool.ts:213-218 - nothing tests the per-entry eviction. I replaced it with
this.instances.delete(key)(which drops the other chain's healthy instance) and all 40 unit tests still pass. Add a test where the admin chain'sclientsetup fails once, then check that the customer chain still gets its existing instance and the admin chain retries. - registry.ts:95 - the
identitydoc still says "a worker keeps one instance per identity". This PR makes that wrong. The type doc at line 66 was updated, but this one was not.
For the maintainer
- This is a semantic change for worker fixtures: one worker can now hold several live instances of the same fixture (one per distinct set of dependency instances), and each lives until the worker ends. That matches the documented intent. Expensive worker fixtures used under many overriding chains will now set up once per chain.
|
[gemini-4-neon] responding on behalf of KrzysztofMoch Addressed both items from the automated review in 812a557:
|
🟢 e2e android: 68 passed, 1 skippedAll 69 tests in 8 files
Tested by e2e 0.25.0 · 11m 54s · android-emulator · run artifacts |
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (AI triage pass), not yet read by a maintainer.
Reviewed 812a557a0. Re-review. Both items from my review of ee3ed9d00 are fixed, and nothing else changed.
Earlier review:
- Eviction test: fixed. fixture-pool.test.ts:672 fails the admin chain's
clientsetup once, then checks that the customer chain keeps its instance and the admin chain retries. Mutation-checked: replacing the per-entry eviction at fixture-pool.ts:213 withthis.instances.delete(key)fails only this test. On the PR, 41/41 pass. identitydoc: fixed at registry.ts:95.
CI is green.
For the maintainer
- Same semantic note as before: one worker can now hold several live instances of a worker fixture, one per distinct set of dependency instances, and each lasts until the worker ends.
- Interplay with #2400 (worker fixtures by import URL): the code doesn't overlap. #2400 changes how
identityis computed, and this PR keys onidentityplus dependency instances, so the two compose. Merging both conflicts indocs/reference/test.mdx(both edit the worker-fixture bullet list near line 1176).worker-fixtures.test.tsmerges cleanly. Whichever lands second rebases and keeps both bullets.
michal-e2e
left a comment
There was a problem hiding this comment.
Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.
Reviewed at 812a557a0. The runtime fix holds: the instance key change is right and fixes the shared-client bug from the description, with one docs gap left before merge.
Must fix
- Please update the docs and skill that still say a worker fixture is set up once per worker and target:
docs/fixtures.mdx:181,docs/reference/test.mdx:1148,skills/e2e/references/writing-tests.md:354(plus its synced copy underplugins/e2e), andpackages/core/src/types.ts:1208(thescope: 'worker'doc comment). Describe it instead as one instance per worker, target and set of instances of the worker fixtures it names, each live until the worker ends. The new bullet in the reference page already says this, so these lines now contradict it. Behavior changes need the matching docs and skill updated in the same PR.
Optional
- Two small test gaps on the instance match, details inline at
fixture-pool.ts:202.
| const known = this.instances.get(key); | ||
| if (known !== undefined) return known; | ||
| const known = this.instances.get(key) ?? []; | ||
| const same = known.find((entry) => entry.inputs.length === inputs.length && entry.inputs.every((input, index) => input === inputs[index])); |
There was a problem hiding this comment.
Can we add a test for overriding a non-first input, such as client naming { region, account } with account overridden? Every new test overrides the first fixture, so they still pass if this match compares only the first input. Can we also add a test for a worker fixture naming a built-in, run first in a plain chain and then in a chain that overrides that built-in with a worker fixture? That catches an entry with fewer inputs matching (<= instead of === on the length). The code is right on both today, so these are only guards.
kdy1
left a comment
There was a problem hiding this comment.
Note
This text was drafted with AI and posted after human approval.
- Harness: T3 Code
- AI agents: coordinator: Claude Opus 5.5 (claude-opus-5-5), reviewer: gpt-6.2-astra, reviewer: gpt-6.2-sol, reviewer: Claude Opus 5.5 (claude-opus-5-5), reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5)
Verdict: Approve
This review approves the pull request. The P3 items are optional and do not block the merge.
Reviewed commit: 812a557a0b9d4d748db538da2457d40dca4c87ee
- P3 (non-blocking): 1 (1 inline)
| declares gets a new instance each time the file is imported again, and | ||
| the old one stays set up until the worker ends: declare it in a module | ||
| the file imports. | ||
| - A worker fixture that names another worker fixture gets a separate instance |
There was a problem hiding this comment.
P3 · Non-blocking · Docs and the skill still say a worker fixture is set up once per worker and target
Optional. This does not block the merge.
This new bullet says that a worker fixture can have more than one instance in a worker. These lines still say that it has one instance, or is set up once, per worker and target:
docs/reference/test.mdx:1148, at the start of the same section, so the page now contradicts itselfdocs/fixtures.mdx:181skills/e2e/references/writing-tests.md:354, and its synced copy underplugins/e2epackages/core/src/types.ts:1208, thescope: 'worker'JSDoc in the public types
Trigger: a user reads the fixtures guide, or an agent reads the skill through e2e guide writing-tests, and expects client to be set up once. At this head, test and adminTest = test.extend({ account }) set up client twice in one worker. The new integration test logs setup:client:admin and setup:client:customer in the same worker.
AGENTS.md ("Contracts") requires a behavior change to update the matching docs/**/*.mdx page and skills/e2e/ in the same change.
Conflict in docs/reference/test.mdx, "Worker fixtures": this branch replaced the bullet on reuse and Bun with four bullets, and #2554 added a bullet after it for fixtures that name an overridden fixture. Kept this branch's four bullets and the bullet of #2554, each word for word. The bullet of #2554 comes second, before the bullets on import URLs.
…(ENG-1553) With #2554 on main a worker fixture is keyed by the instances of the worker fixtures it names. So when another resolve hook makes the runner set a fixture up again, each worker fixture that names it is set up again too.
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-v2-3x.png)
What
A worker fixture that depends on another worker fixture now gets a separate instance for each
test.extend()chain that overrides one of its dependencies, directly or through another fixture. Chains that share every worker fixture it names still share one instance.Why
WorkerFixturePool.acquirecached each worker fixture solely by its ownidentity. Whenclientdepended onaccountand another file definedadminTest = test.extend({ account }), both chains resolvedclientto the same cached instance. Whichever file ran first setclientfor the rest of the worker, so the second file got the wrong account's client.How it works
WorkerFixturePool.instancesmaps each fixture key (definition.identity ?? definition) to a list ofWorkerInstanceentries holding{ inputs, instance }, whereinputsare the instance promises returned byacquirefor the chain worker fixtures it depends on (packages/e2e/src/run/fixture-pool.ts:140,packages/e2e/src/run/fixture-pool.ts:199). On lookup,acquirereuses an entry only when allinputsmatch by reference; on setup failure, only that entry is evicted.bindFixturestracks theacquirepromise for each worker fixture inworkerInstances(packages/e2e/src/run/fixture-pool.ts:321) and passes the resolved dependency promises in declaration order topool.acquire, leaving built-in fixtures out of the key (packages/e2e/src/run/fixture-pool.ts:354-359). Keying by instance promise rather than by definition handles transitive overrides (client -> link -> account), and keying by promise rather than resolved value handles overrides that pass the extended object through.packages/e2e/src/collect/registry.ts:66), documented the instance rule under worker fixtures (docs/reference/test.mdx:1185), and added a patch changeset fore2e.packages/e2e/tests/unit/fixture-pool.test.ts), plus a runner integration test for the two-file repro in both orders (packages/e2e/tests/integration/worker-fixtures.test.ts).Issue
ENG-1400
Verified
Ran it locally: yes
node node_modules/e2e/dist/cli/bin.js run) on a two-file repro project (workers: 1,retries: 0) wheretests/support.tsdefines worker fixturesaccountandclient,tests/user.e2e.tsusestest, andtests/admin.e2e.tsoverridesaccountwithbase.extend:tests/user.e2e.tsfails:ERROR: expected client:user, got client:admin(1 failed | 1 passed (2))2 passed (2))apps/testbed:tests/hooks.e2e.tspasses (7 passed (7)in 2.50s).pnpm bench:ab: this change adds a reference equality check over a fixture's dependency list on worker-fixture acquisition and does not alter attempt scheduling or execution loops.isolation: 'worker'), serial groups, andbox(all go through the samebindFixtures->acquirepath).Summary by CodeRabbit
Bug Fixes
Documentation