-
-
Notifications
You must be signed in to change notification settings - Fork 535
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Support Edge Runtime (no http module) #1428
Comments
From a brief inspection, this looks like it would be supported by creating a third startup option: |
I wonder if we should use interceptors based on the availability of those modules. setupServer([
typeof XMLHttpRequest !== 'undefined' && XMLHttpRequestInterceptor
]) Will be hard to figure out Node.js built-ins like Overall, edge support would be great but I don't see it as a priority anytime soon. If someone would like to make this happen without reworking much of the library, I'd be open to releasing it. I think the conceptual issue here is that such Edge runtimes are still a custom thing. They do respect the standards but |
To make things a little more complex, there's no such thing as a standardized Edge environment. There's the browser and there's Node.js. I suppose edge frameworks try to emulate Node.js but may be implemented in different languages and the standard library is usually limited and incomplete. This makes it not an actual environment, really, but an infinite list of subsets of an environment. Indeed, things may get a little easier with Edge frameworks adopting web standards, which some of the most popular ones already do, and MSW adopting them as well. But both those things need to happen for us to claim Edge support, for "Edge" is not really the same thing when referred to by different people. I may be terribly wrong on these things so do not hesitate to correct me. |
I will also move this to a discussion because, as I've said, there's no intention on working on this any time soon. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Scope
Improves an existing behavior
Compatibility
Feature description
NextJS has introduced an Edge Runtime (more docs here, which is a stricter node.js runtime based on web standards to run "on the edge". This is used, for example, but their middleware.
I am performing user authentication in this middleware, and would like to mock the
fetch
requests I make in my middleware. This means I need MSW to be compatible with the edge runtime and support intercepting fetch requests made there.I have cloned the with-msw example and added a
middleware.ts
file which makes a simplefetch
request. The failure can be seen in my repository: with-msw-appThe error I see when trying to run this is:
The text was updated successfully, but these errors were encountered: