Skip to content

fix: do not abort atoms on unmount#2627

Merged
dai-shi merged 1 commit intopmndrs:mainfrom
Pinpickle:no-abort-unsub
Jun 28, 2024
Merged

fix: do not abort atoms on unmount#2627
dai-shi merged 1 commit intopmndrs:mainfrom
Pinpickle:no-abort-unsub

Conversation

@Pinpickle
Copy link
Contributor

Related Bug Reports or Discussions

Fixes #2625

Summary

@dai-shi agreed that not aborting promises on unsubscription was the best solution here.

When added to the continuable/cancellable promise idiom, it makes quite a lot of sense. Only abort the promise if you can replace it with another one.

I added the behaviour to store and store2

Check List

  • pnpm run prettier for formatting code and docs

@vercel
Copy link

vercel bot commented Jun 20, 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 Jun 27, 2024 5:03am

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 20, 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.

@github-actions
Copy link

github-actions bot commented Jun 20, 2024

LiveCodes Preview in LiveCodes

Latest commit: fe3fad5
Last updated: Jun 27, 2024 5:03am (UTC)

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

See documentations for usage instructions.

@Pinpickle
Copy link
Contributor Author

@dai-shi

 ❯ |jotai| tests/react/abortable.test.tsx  (4 tests | 1 failed) 4208ms
   ❯ tests/react/abortable.test.tsx > abortable atom test > can abort on unmount
     → expected +0 to be 1 // Object.is equality

What do we want to do here? As far as I can tell, it's impossible to satisfy this test case.

@dai-shi
Copy link
Member

dai-shi commented Jun 21, 2024

can abort on unmount

Yeah, it's the test case we will break. Just remove it?

@dai-shi
Copy link
Member

dai-shi commented Jun 26, 2024

☝️ @Pinpickle

@Pinpickle
Copy link
Contributor Author

@dai-shi sorry! I've pushed the fix now. I've kept the test to assert that there are no aborts on unmount so this behaviour doesn't get reverted :)

@Pinpickle
Copy link
Contributor Author

Oops, had a TS error. Fixed now!

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.

LGTM
Thanks for your contribution!

})

it('can abort on unmount', async () => {
it('does not abort on unmount', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('does not abort on unmount', async () => {
it('does not abort on unmount (#2627)', async () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense! Though I see you've already merged!

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I forgot to apply changes. 😓

@dai-shi dai-shi added this to the v2.8.4 milestone Jun 27, 2024
@dai-shi dai-shi merged commit 2c3c658 into pmndrs:main Jun 28, 2024
@Pinpickle
Copy link
Contributor Author

Thanks @dai-shi!

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.

Atoms aborted due to unmount are unrecoverable

2 participants