Stop the draft attachment snapshot test leaning on a leaked rAF - #910
Merged
Merged
Conversation
`updateNode` batches its dirty-node flush through `requestAnimationFrame`, which bun's test runtime has no DOM to supply. Seven other core tests that reach this path stub it; this one did not, and passed only when bun happened to run one of them first and leak the global. On a runner that ordered the files differently it failed with a bare ReferenceError, and running the file on its own failed every time. Stubs rAF for the duration of the test and restores it in the existing finally, matching how the neighbouring store tests do it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: a4b5a434-b9a1-4be7-a90b-7d777d724d89 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draft-attachment-snapshot.test.tsfails with a bareReferenceError: requestAnimationFrame is not defineddepending on the order bun happens to run the core test files in. It surfaced on a private-editor CI run, on a diff that touched nothing in the editor.Cause
updateNodebatches its dirty-node flush throughrequestAnimationFrame(store/actions/node-actions.ts:1465), which bun's test runtime has no DOM to supply. Seven other core tests that reach this path stub the global themselves —use-scene-dirty-tracking,node-update-children,wall-merge,host-children,procedural-persistence,procedural-items/mutations,use-scene-temporal-reconciliation. This one never did, so it passed only when one of those ran first and leakedglobalThis.requestAnimationFramebehind it. Run the file on its own and it fails every time, onmainas much as anywhere:Fix
Stub rAF for the duration of the test and restore it in the
finallythat's already there, matching the idiom in the neighbouring store tests.Testing
bun test src/store/draft-attachment-snapshot.test.tson its own: passes (failed before).bun test srcinpackages/core: 2865 pass, 0 fail.updateNode/updateNodeswithout stubbing rAF —registry/scene-api.test.tsis the only other one, and it passes standalone because it doesn't reach the batched path. No further latent cases.🤖 Generated with Claude Code
https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
Note
Low Risk
Test-only change with no production code or runtime behavior impact.
Overview
Fixes order-dependent flakiness in
draft-attachment-snapshot.test.ts: the test callsupdateNode, which schedules a dirty-node flush viarequestAnimationFrame, but Bun’s test environment has no DOM globals.The test now stubs
globalThis.requestAnimationFrameandcancelAnimationFramefor the duration of the scenario and restores the originals in the existingfinallyblock, matching other core store tests. It no longer relies on another test file having run first and leaked a stub ontoglobalThis.Reviewed by Cursor Bugbot for commit 07e0251. Bugbot is set up for automated code reviews on this repo. Configure here.