create-react-app-vite
create-react-app-vite copied to clipboard
Race Condition with Worker
Currently the worker.start() is not being returned or awaited, sometimes that will cause the worker to be started after react renders. Causing conflicts with React Router. Simple return should be able to fix this issue.
import('../mocks/browser')
.then(async ({ worker }) => {
worker.start() // Will cause a race condition if not awaited or returned.
}) // Run <App /> when Service Worker is ready to intercept requests.
.then(() => {
root.render(<App />)
})