create-react-app-vite icon indicating copy to clipboard operation
create-react-app-vite copied to clipboard

Race Condition with Worker

Open NateAGeek opened this issue 1 year ago • 0 comments

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 />)
    })

NateAGeek avatar Aug 27 '24 21:08 NateAGeek