Fix xhr race condition