mirror of
https://github.com/Comfy-Org/comfy-typescript-sdk.git
synced 2026-11-04 23:47:27 +00:00
[PR #125] [MERGED] test(credentials): unstub globals before envs so the hook cannot throw #126
Labels
No labels
audit:ai-readiness
audit:community
audit:github
audit:health-scoring
audit:policy
audit:release
audit:supply-chain
bug
cursor-review-pin
effort:medium
effort:small
effort:trivial
priority:nice-to-have
priority:recommended
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-typescript-sdk#126
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/125
Author: @mattmillerai
Created: 9/4/2026
Status: ✅ Merged
Merged: 9/4/2026
Merged by: @mattmillerai
Base:
main← Head:matt/fix-credentials-test-unstub-order📝 Commits (1)
851c1f4test(credentials): unstub globals before envs so the hook cannot throw📊 Changes
2 files changed (+6 additions, -2 deletions)
View changed files
📝
src/sdk/credentials.test.ts(+5 -1)📝
src/sdk/models.test.ts(+1 -1)📄 Description
Two-line fix.
pnpm testis red on Node 26 — 17 failures — and green on theNode versions CI runs.
ELI-5
Two tests in
credentials.test.tsdeleteprocessto prove the SDK degradesgracefully in a runtime that has no such thing (a browser). The cleanup hook
that runs after every test then tries to put the environment variables back,
and it reaches them through
globalThis.process.env— which is exactly thething the test just deleted. So the cleanup crashes partway through, before
it gets to the line that would have restored
process.processstays gone for the rest of the file, and every test after those twofails on the same missing global. Two real assertions become 17 red tests.
The fix is to restore the globals first, then the environment variables, so
there is a
processto restore them into.Why CI didn't catch it
It depends on how the runtime hands
processto vitest's env restore.pnpm testengines.nodeis>= 22and CI matrixes 22 and 24, so nothing on therequired checks sees this. It shows up as soon as you run the suite on a
current Node locally.
Scope
src/sdk/credentials.test.ts— the live failure. Hook order swapped, with acomment saying why the order matters, so the next person does not swap it
back.
src/sdk/models.test.ts— same hook shape, but it only stubsfetch, sothe bug is latent rather than live there. Swapped too, since a future test
that stubs a global the env restore depends on would hit the identical
trap.
No source file is touched.
Verification
pnpm teston Node 26: 432 passed, 0 failed (was 415 passed / 17 failed).The two
processtests still assert what they always did — they were passingon their own bodies all along; it was their cleanup that failed.
pnpm lint,pnpm format:check,pnpm typecheckand the hygiene check are clean.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.