Fix race condition

[ci skip]