Skip to content

Commit 8f63933

Browse files
test(config): probe the reset guard after the first delete rejects
The #2236 row on ContextProxy.spec.ts:1345 says the mid-settling storeSecret in my case happens before the failing delete's rejection handler can run, so a regression that clears the guard after that failure and still leaves a delete outstanding would pass this test as written. It measures true. I built the regression the row names - every delete promise wrapped so its rejection handler sets resetting = false and rethrows, a shape tsc accepts (exit 0 on that tree) - and measured the pairing against 6516269, the commit this sits on: case as shipped vs the regression shape 73 passed (73) - blind, the premise is right case plus the tick vs the regression shape 1 failed | 72 passed (73) - catches it case plus the tick vs the shipped proxy 73 passed (73) - not a false alarm about prod case as shipped vs the shipped proxy 73 passed (73) - control The change is a 0 ms tick between the timer that releases the pending delete and the storeSecret probe, so the probe lands after the rejection handler has had its turn and while the apiKey delete is still outstanding. The tick fires before the 20 ms one, so stragglerLanded still means what the case says it means, and the assertion that was already there is the one that goes red. The pairing is placement-sensitive and that belongs in the record. An earlier variant of the same regression - .catch without the Promise.resolve hop, which tsc rejects because a Memento delete returns a Thenable rather than a Promise - reddened the pre-existing case about not restoring a pre-reset value while a rejected write settles instead of this one, so which case catches the class depends on where the extra microtask hop lands. Anyone who moves this tick should re-measure the pairing rather than assume it still holds. The second half is what CI actually reddened. bseries ran the package's own gate on 6516269 and I reproduced it here: pnpm --dir src run lint exits 1 with 5 problems, all in this file, at 29:19, 30:23, 31:19, 1263:12 and 1279:12, and no other file reports anything. My commit 96c9157 lowered this file's no-explicit-any entry from 5 to 4 while the file still held five occurrences, and the merge kept my side of that hunk. What that commit message claimed - that the entry was already stale at 677e5e3 - was wrong: the prune run I quoted in the same session wrote 5 for the file, which is what five occurrences looks like, and the green I quoted came from a per-file eslint invocation, which does not reproduce what eslint . reports against eslint-suppressions.json. The gate that matters is the package script, and I had not run it. So two of the five are typed now: the two matcher predicates became (call: unknown[]), which is the shape the neighbouring case in this same file already uses, and the entry records 3, which is what eslint --prune-suppressions writes for this file and what the package gate agrees with. The three let mockContext / mockGlobalState / mockSecrets doubles at 29, 30 and 31 stay as they are, and they are the follow-up this row does not pay off: typing them needs either an explicit any inside a Mock type argument, which buys nothing, or a typed double in src/test-utils/vscode.ts - makeExtension Context takes Partial<ExtensionContext>, so a secrets double has to carry onDidChange, and the helper already hides its one unavoidable cast behind as unknown as vscode.ExtensionContext at line 159. That is a shared test-util change, not a line of this row. One run against the tree this commit makes: pnpm --dir src run lint exit 0 with the eslint cache cleared first (the cache path lives in a junctioned node_modules), tsc --noEmit -p . exit 0, eslint --prune-suppressions on this file exit 0 with its entry staying 3, prettier --check exit 0 on both touched files, ContextProxy.spec.ts 73 passed (73), CustomModesManager.spec.ts 53 passed (53), ClineProvider.spec.ts 389 passed (389) and core/config 324 passed (324). ContextProxy.ts is untouched, blob 64023b9 before and after. No mutant count is quoted here: local Stryker cannot start in this environment, so this commit quotes no digest it cannot produce. git diff --cached --numstat for exactly what is staged here: 7 2 src/core/config/__tests__/ContextProxy.spec.ts 1 1 src/eslint-suppressions.json Thread PRRT_kwDOSK-bwM606PC6 gets the E/F/G trio in a reply, and it is resolved because it is answered.
1 parent 6516269 commit 8f63933

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/core/config/__tests__/ContextProxy.spec.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ Output only the summary of the conversation so far, without any additional comme
12601260
// Should NOT have called update for customSupportPrompts (custom prompt should be preserved)
12611261
const updateCalls = mockGlobalState.update.mock.calls
12621262
const customSupportPromptsUpdateCalls = updateCalls.filter(
1263-
(call: any[]) => call[0] === "customSupportPrompts",
1263+
(call: unknown[]) => call[0] === "customSupportPrompts",
12641264
)
12651265
expect(customSupportPromptsUpdateCalls.length).toBe(0)
12661266
})
@@ -1276,7 +1276,7 @@ Output only the summary of the conversation so far, without any additional comme
12761276
// Should not have called update for customSupportPrompts
12771277
const updateCalls = mockGlobalState.update.mock.calls
12781278
const customSupportPromptsUpdateCalls = updateCalls.filter(
1279-
(call: any[]) => call[0] === "customSupportPrompts",
1279+
(call: unknown[]) => call[0] === "customSupportPrompts",
12801280
)
12811281
expect(customSupportPromptsUpdateCalls.length).toBe(0)
12821282
})
@@ -1338,6 +1338,11 @@ Output only the summary of the conversation so far, without any additional comme
13381338
})
13391339
const reset = proxy.resetAllState()
13401340
setTimeout(() => landStraggler?.(), 20)
1341+
// Probe the guard after the first delete's rejection handler has had its turn, not before it: a
1342+
// guard that comes down on the failure while a delete is still outstanding has to be caught here,
1343+
// not only by the straggler assertion further down. The 0 ms tick lands before the 20 ms one, so
1344+
// the pending delete is still pending when the probe runs.
1345+
await new Promise((resolveTick) => setTimeout(resolveTick, 0))
13411346
// While the pass is still settling the guard is up, so a save here is refused rather than
13421347
// accepted and erased later. That refusal is the observable the fix bought.
13431348
await expect(proxy.storeSecret("apiKey", "mid-settling-save")).rejects.toThrow(

‎src/eslint-suppressions.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@
536536
},
537537
"core/config/__tests__/ContextProxy.spec.ts": {
538538
"@typescript-eslint/no-explicit-any": {
539-
"count": 4
539+
"count": 3
540540
}
541541
},
542542
"core/config/__tests__/CustomModesManager.exportImportSlugChange.spec.ts": {

0 commit comments

Comments
 (0)