Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js 13 issue #1479

Closed
4 tasks done
harisliv opened this issue Nov 27, 2022 · 4 comments
Closed
4 tasks done

Next.js 13 issue #1479

harisliv opened this issue Nov 27, 2022 · 4 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser

Comments

@harisliv
Copy link

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 14 or higher

Browsers

Chromium (Chrome, Brave, etc.)

Reproduction repository

https://github.com/harisliv/next13-msw049.git

Reproduction steps

First install the dependencies with npm install and after run the app with npm run dev .

Current behavior

Right now with latest Next and msw the first fetch is not being caught by the MSW. You need to press the button and re-fetch to do so.

image

Expected behavior

First fetch should be caught by the MSW. The same example in Next12 works as expected!

@harisliv harisliv added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser labels Nov 27, 2022
@kettanaito
Copy link
Member

Hey, @harisliv.

This is a known issue and I think it concerns even the previous versions of Next. The root cause for this is that the Next template uses a dynamic import but never awaits the Promise that import returns. This creates a race condition between the MSW setup being imported and your application's logic potentially making an on-mount request.

I've raised this in the Next repository (see vercel/next.js#43284). I propose we tackle it there, the issue is not related to the library itself but rather to how it's being set up in Next projects.

@harisliv harisliv changed the title Nest.js 13 issue Next.js 13 issue Nov 28, 2022
@harisliv
Copy link
Author

Hey, @kettanaito
This is issues is not happening in Next 12.
Anyway i will keep track of the process.
Thanks :)

@kettanaito
Copy link
Member

That may be dependent on the changes the Next team introduced in Next 13. Technically, that should still happen in any code because not awaiting the import promise is a race condition.

@harisliv
Copy link
Author

Yes that makes sense.
Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser
Projects
None yet
Development

No branches or pull requests

2 participants