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

lib: Fix race condition in "double dialog" error check #19616

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

martinpitt
Copy link
Member

useState() setters are async. c-podman and navigator call Dialogs.close(); Dialogs.show(...) in direct succession. In that case, Dialogs.show() does not yet see the updated null value for dialog and logs the error, which fails the test.

To avoid that, use a ref for "is the dialog open", which is synchronous.


Spotted in cockpit-project/cockpit-files#156 and cockpit-project/cockpit-podman#1484 .

useState() setters are async. c-podman and navigator call
`Dialogs.close(); Dialogs.show(...)` in direct succession. In that case,
Dialogs.show() does not yet see the updated `null` value for `dialog`
and logs the error, which fails the test.

To avoid that, use a ref for "is the dialog open", which is synchronous.
@martinpitt martinpitt merged commit 140b7e6 into cockpit-project:main Nov 16, 2023
86 of 91 checks passed
@martinpitt martinpitt deleted the dialog-warning-sync branch November 16, 2023 09:30
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