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

Support Remix Single Fetch (v3_unstable_singleFetch) #2393

Open
4 tasks done
kettanaito opened this issue Dec 14, 2024 · 1 comment
Open
4 tasks done

Support Remix Single Fetch (v3_unstable_singleFetch) #2393

kettanaito opened this issue Dec 14, 2024 · 1 comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@kettanaito
Copy link
Member

Prerequisites

Environment check

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

Node.js version

18/20

Reproduction repository

Reproduction steps

  1. Create a new Remix app today. It will have Single Fetch enabled.
  2. Integrate MSW server-side.

Current behavior

MSW doesn't intercept any server-side requests (e.g. requests you make in your loaders) because they are invisible to MSW. Remix has to implement a single connection that routes multiple requests, and as such they are not individual requests that MSW can recognize and handle (this is my wild guess).

Expected behavior

MSW handles server-side requests when Single Fetch is enabled in Remix.

Important

This works fine with Single Fetch disabled.

@kettanaito kettanaito added bug Something isn't working scope:node Related to MSW running in Node needs:triage Issues that have not been investigated yet. labels Dec 14, 2024
@kettanaito
Copy link
Member Author

Overall, the fact that requests aren't being made is concerning. MSW doesn't ship any framework-specific logic, operating on the sensible assumption that when you make a request, you trigger the network code (e.g. fetch or http.ClientRequest in Node.js). If you don't, you aren't really making any requests and MSW cannot do much about that.

I've skimmed through the Remix and React Router source code relevant for Single Fetch, but didn't find any indication that they would silence or patch request-issuing APIs to achieve network collocation under a single fetch request. It looks like they just flush all requests for a single route from all the affected loaders/actions, then wait for them in parallel, then feed that data to the loaders.

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:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

1 participant