Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): robust flush batch #2871

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Conversation

dmaskasky
Copy link
Collaborator

@dmaskasky dmaskasky commented Dec 17, 2024

Summary

The recent refactor #2868 to batching causes a subtle regression in which errors thrown in listeners could cause the remaining listeners for that atom not to run.

This PR flattens listeners to the pending function so errors thown are detected but only rethrown after the remaining listeners have been processed.

Check List

  • pnpm run prettier for formatting code and docs

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 2:48am

Copy link

codesandbox-ci bot commented Dec 17, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

pkg-pr-new bot commented Dec 17, 2024

Open in Stackblitz

More templates

npm i https://pkg.pr.new/jotai@2871

commit: 035007c

Copy link

github-actions bot commented Dec 17, 2024

LiveCodes Preview in LiveCodes

Latest commit: 035007c
Last updated: Dec 18, 2024 2:47am (UTC)

Playground Link
React demo https://livecodes.io?x=id/D3A5T2E35

See documentations for usage instructions.

@dai-shi
Copy link
Member

dai-shi commented Dec 18, 2024

Nice catch. I forgot about that calling a listener can throw.

@dmaskasky dmaskasky force-pushed the fix/robust-flushBatch branch from d9178e7 to ecb4fa9 Compare December 18, 2024 02:29
@dmaskasky dmaskasky requested a review from dai-shi December 18, 2024 02:42
@dai-shi dai-shi changed the title Fix/robust flush batch fix(store): robust flush batch Dec 18, 2024
src/vanilla/store.ts Outdated Show resolved Hide resolved
Co-authored-by: Daishi Kato <[email protected]>
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@dai-shi dai-shi added this to the v2.11.0 milestone Dec 18, 2024
@dai-shi dai-shi merged commit 8c37913 into pmndrs:main Dec 18, 2024
42 checks passed
@dmaskasky dmaskasky deleted the fix/robust-flushBatch branch December 18, 2024 03:01
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