fix publish race condition