Skip to content

fix(components): validate Spinner intervals and release rejected timers - #303

Merged
hyfdev merged 1 commit into
mainfrom
codex/spinner-interval-final
Sep 7, 2026
Merged

hyfdev merged 1 commit into
mainfrom
codex/spinner-interval-final

Conversation

@hyfdev

@hyfdev hyfdev commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Spinner rejects delays outside 1–2147483647 integer milliseconds and releases the previous timer before validating an update.

interval: 20 → 0 → 40
active timers: 1 → 0 → 1

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.

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
hyfdev force-pushed the codex/spinner-interval-final branch from 0c542ef to 8349f25 Compare September 7, 2026 14:53
@hyfdev
hyfdev marked this pull request as ready for review September 7, 2026 14:57
Copilot AI lite review requested due to automatic review settings September 7, 2026 14:57
@hyfdev
hyfdev merged commit c0de5dc into main Sep 7, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 interval validation and safer preset lookup (avoids inherited Object.prototype members being treated as presets) in resolveSpinner.
  • Refactor <Spinner>’s timer lifecycle to rely on watcher cleanup (clearing the prior interval before validation can throw) and remove manual onScopeDispose timer 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: "",
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants