Skip to content

fix(core): dispose effects when model factory throws - #987

Open
SisyphusZheng wants to merge 2 commits into
preactjs:mainfrom
SisyphusZheng:codex/fix-model-factory-effect-cleanup
Open

SisyphusZheng wants to merge 2 commits into
preactjs:mainfrom
SisyphusZheng:codex/fix-model-factory-effect-cleanup

Conversation

@SisyphusZheng

@SisyphusZheng SisyphusZheng commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #986

Summary

Dispose captured effects when a createModel factory throws. Previously, the error handler cleared the capture list without cancelling subscriptions or running cleanup callbacks.

Disposal is batched so cleanup writes do not rerun effects awaiting disposal. If a cleanup throws, remaining effects are still disposed and the original factory error is preserved.

Testing

  • Added regression tests for disposal/unsubscription and cleanup callbacks that update a signal and throw.
  • Core and React/Preact useModel tests: 181 passed, 2 skipped.

AI assistance

This contribution was developed with assistance from AI.

Implementation and regression tests assisted by OpenAI Codex.
@changeset-bot

changeset-bot Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f0785ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@preact/signals-core Patch
preact-signals-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit f0785ab
🔍 Latest deploy log https://app.netlify.com/projects/preact-signals-demo/deploys/6abe8ba082a7970008a9f6cc
😎 Deploy Preview https://deploy-preview-987--preact-signals-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
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.

bug:createModel leaves effects subscribed when the factory throws

1 participant