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

Race condition in 5.1.0 when using rerender and unmount #692

Open
mdonnalley opened this issue Jan 15, 2025 · 0 comments
Open

Race condition in 5.1.0 when using rerender and unmount #692

mdonnalley opened this issue Jan 15, 2025 · 0 comments

Comments

@mdonnalley
Copy link

We use the rerender method to tigger a new rendering of a component and then later call unmount when we're done with it. This has worked well for our use case but after upgrading to 5.1.0, we're seeing a race condition that's causing the component to render after the component has been unmounted.

I created a repo that replicates the issue

git clone https://github.com/mdonnalley/ink-bug.git
cd ink-bug
npm install
node --loader=import-jsx index.js

With 5.1.0

--- Time to render the component  ---
Hello Foo!
--- Done! ---
Hello Baz!

With 5.0.1

--- Time to render the component  ---
Hello Baz!
--- Done! ---

Best I can tell the regression is caused by this PR, which swapped lodash's throttle for es-toolkit's.

Our best workaround at the moment is to pin ink to 5.0.1 but it's not a great long term solution since we'd like to stay up to date with latest.

We also considered adding a 10ms sleep before unmounting the component. This seems to work but it would require some painful refactoring on our end to make the entire call stack async.

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

No branches or pull requests

1 participant