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(weakCache): Replace recursion with while loop to avoid too much recursion #633

Merged
merged 3 commits into from
Aug 3, 2021

Conversation

Thisen
Copy link
Collaborator

@Thisen Thisen commented Aug 2, 2021

Fixes #630

@vercel
Copy link

vercel bot commented Aug 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/FR2N4jSDXSLGQHL4b3yZ1c5EBHXs
✅ Preview: https://jotai-git-fix-waitforall-too-much-recursion-pmndrs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 2, 2021

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.

Latest deployment of this branch, based on commit 073b470:

Sandbox Source
React Configuration
React Typescript Configuration
jolly-turing-g3h5f Issue #630

@dai-shi
Copy link
Member

dai-shi commented Aug 2, 2021

Great you found a solution!
I'd like to understand the issue and possibly come up with alternative solution.

So, is this only the issue with the weakCache? If we didn't use getWeakCacheItem by commenting out, would the test pass? (well, I can try...)

@Thisen
Copy link
Collaborator Author

Thisen commented Aug 3, 2021

The issue seems to be too much recursion, JS doesn't handle that very well. Another solution would be a for loop, but I'm not sure how you would do that, given the current algorithm, where you push the item into the entry in setWeakCacheItem>

@dai-shi
Copy link
Member

dai-shi commented Aug 3, 2021

Oh, I see. It's recursion. Yeah, I kind of knew this would happen.
I think we can implement with for-loop. Would you like to try or want me to try?

@Thisen Thisen marked this pull request as ready for review August 3, 2021 06:52
@Thisen Thisen changed the title Add trampoline to avoid too much recursion fix(weakCache): Replace recursion with for-loop to avoid too much recursion Aug 3, 2021
@Thisen Thisen requested a review from dai-shi August 3, 2021 06:53
@Thisen Thisen changed the title fix(weakCache): Replace recursion with for-loop to avoid too much recursion fix(weakCache): Replace recursion with while loop to avoid too much recursion Aug 3, 2021
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.

Yay! Thanks for finding the solution and fixing it!

@dai-shi dai-shi merged commit e1aa6bb into master Aug 3, 2021
@dai-shi dai-shi deleted the fix/waitforall-too-much-recursion branch August 3, 2021 07:17
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.

waitForAll inside selector throws with a lot of atoms
2 participants