Avoid ServeApi race condition Upstream-commit: 596ddef7d73273103a7b900fa46d4392e1d3e27b Component: engine