-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
with-msw example is not compatible with experimental appDir setting in next.config.js #43758
Comments
Same problem as #43284, closing in favor. |
This is not a duplicate as raised against Next 13 beta features. MSW fetching works ok if appDir feature is disabled. The other issue is raised against Next 12 which has no appDir. This is not only a different test, it's a major upgrade. Even if the cause is the same these are two different environments and fixing the other issue will not guarantee a fix of this issue. |
The root cause is that MSW requires a way to initialize some async logic before the server starts, which the other issue is about. As for app directory support, it's currently in beta and we do not expect to convert current examples just yet. We will revisit support in examples when things have stabilized a bit more. Until then, I recommend asking for support/workarounds from the library author if you wish to experiment. (who is present in the linked issue). Note that app directory is not ready yet for production as documented https://beta.nextjs.org/docs |
That's not entirely true. To draw a full picture, people want to capture outgoing requests that happen on application's mount. To do that, MSW should be imported (not even started) before mount, which is logical. Because once you import it, it will capture any outgoing requests and defer them until the worker is ready (speaking of the in-browser usage as an example). You don't have to await anything. The issue itself is that using a dynamic import to require MSW creates a Promise that nothing awaits currently. This won't happen with synchronous @balazsorban44 has also proposed a workaround (#43284 (comment)) that can use both dynamic import and await its resolution before rendering the app. I believe it should work. |
Thanks for the link. The example provided relates to the pages folder, and the app folder works differently using a modified fetch function. Could this workaround be adapted for the Next 13 folder structure and applied to the Layout.tsx and Page.tsx files? |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
The with-msw example is not compatible with the appDir expeimental features enabled.
My base nextjs.config.js file looks like this:
Starting wih appDir: false works correctly
starting with appDir = true fails with errors
To clarify the only difference here is setting appDir to true.
Which example does this report relate to?
with-msw
What browser are you using? (if relevant)
chrome
How are you deploying your application? (if relevant)
No response
Describe the Bug
Fully described in relevant information.
Expected Behavior
experimental appDir beta features should be fully compatible with the with-msw Next example.
To Reproduce
Fully described in relevant information.
The text was updated successfully, but these errors were encountered: