Skip to content

fix(core): copy hooks before iterating in callHook - #166

Merged
pi0 merged 1 commit into
unjs:mainfrom
danielroe:fix/hookable-unreg
Sep 17, 2026
Merged

pi0 merged 1 commit into
unjs:mainfrom
danielroe:fix/hookable-unreg

Conversation

@danielroe

@danielroe danielroe commented Sep 17, 2026

Copy link
Copy Markdown
Member

spotted this issue I recall previously fixing in #79

(the wheel turns!)

Summary by CodeRabbit

  • Bug Fixes
    • Improved hook execution reliability when a hook removes itself during an event, ensuring subsequent hooks still run.
  • Tests
    • Added coverage for hooks unregistering themselves during execution.
    • Updated bundle size regression thresholds to reflect current output.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 948cdb80-332f-4c01-81e9-54bd17928e60

📥 Commits

Reviewing files that changed from the base of the PR and between b77477c and 82426ea.

📒 Files selected for processing (3)
  • src/hookable.ts
  • test/bundle.test.ts
  • test/hookable.test.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Hook iteration safety

Layer / File(s) Summary
Snapshot hook lists and validate dispatch
src/hookable.ts, test/hookable.test.ts, test/bundle.test.ts
HookableCore.callHook passes a copied hook list to callHooks. A test verifies that remaining hooks run after self-unregistration. Bundle-size thresholds are updated.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 82426

The hook iteration fix and regression coverage do not indicate a remaining merge-blocking issue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: copying hooks before iteration in callHook to prevent mutation-related hook execution issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pi0
pi0 merged commit 20fc8cd into unjs:main Sep 17, 2026
2 checks passed
@danielroe
danielroe deleted the fix/hookable-unreg branch September 17, 2026 13:45
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