Repository navigation
fix(components): validate Spinner intervals and release rejected timers - #303
Merged
Merged
Conversation
Validate frame delays before starting a timer. Watch raw props so cleanup precedes validation on live changes, and restart when valid input returns. Resolve unknown preset names through own properties only.
hyfdev
force-pushed
the
codex/spinner-interval-final
branch
from
September 7, 2026 14:53
0c542ef to
8349f25
Compare
hyfdev
marked this pull request as ready for review
September 7, 2026 14:57
There was a problem hiding this comment.
🟢 Approval recommended
The changes align implementation, tests, and documentation around a clear interval/timer contract, with only a minor test-diagnostics improvement suggested.
Pull request overview
This PR hardens the <Spinner> component’s interval handling by validating interval bounds (1–2147483647ms, safe integer only), ensuring timers are cleaned up via Vue watcher cleanup semantics (including on rejected updates), and documenting/testing the resulting behavior.
Changes:
- Add strict
intervalvalidation and safer preset lookup (avoids inheritedObject.prototypemembers being treated as presets) inresolveSpinner. - Refactor
<Spinner>’s timer lifecycle to rely on watcher cleanup (clearing the prior interval before validation can throw) and remove manualonScopeDisposetimer teardown. - Expand coverage with resolver tests, sequential timer-harness tests, and a production-mode subprocess fixture validating rejected updates and cleanup; update docs/README to match the new contract.
File summaries
| File | Description |
|---|---|
| packages/components/src/spinner/spinners.ts | Adds interval validation + safer preset resolution to prevent inherited keys from being treated as presets. |
| packages/components/src/spinner/spinner.vue | Moves timer ownership to watcher cleanup to ensure timers are cleared before validation errors can throw. |
| packages/components/tests/spinner/spinners.test.tsx | Adds coverage for inherited preset-name fallbacks and invalid interval rejection/message formatting. |
| packages/components/tests/spinner/spinner.sequential.test.tsx | Adds a sequential test ensuring invalid initial intervals start no timer. |
| packages/components/tests/spinner/rejected-interval-production.test.ts | Adds a production subprocess test to validate rejection + cleanup behavior under production error handling. |
| packages/components/tests/spinner/fixtures/rejected-interval-production.mjs | Production fixture that asserts timer creation/cleanup across invalid updates and unmount. |
| packages/components/README.md | Documents the stricter interval contract (bounds + TypeError). |
| .agents/docs/components/spinner.md | Updates the Spinner decision record to describe the new interval validation and timer-cleanup behavior. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+30
to
+33
| expect({ code: exit, stderr: stderr.includes("AssertionError") ? stderr : "" }).toEqual({ | ||
| code: 0, | ||
| stderr: "", | ||
| }); |
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.
Spinner rejects delays outside 1–2147483647 integer milliseconds and releases the previous timer before validating an update.
Fix
Timer ownership follows Vue watcher cleanup. The watcher reads raw props, validates inside its callback, and registers cleanup for each accepted timer. Unknown preset names, including Object.prototype member names, select the documented dots fallback.
Validation
A production-mode subprocess checks invalid initial input, timer cleanup after an invalid update, recovery to a valid delay, and unmount cleanup. Component tests cover animation, interval changes and preset fallback; resolver tests cover delay bounds.
Implemented and reviewed with AI assistance. Part of #286.