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

Consider implementing WebSocket-based remote interception #420

Open
kettanaito opened this issue Sep 10, 2023 · 0 comments
Open

Consider implementing WebSocket-based remote interception #420

kettanaito opened this issue Sep 10, 2023 · 0 comments

Comments

@kettanaito
Copy link
Member

Our RemoteHttpResolver/RemoteHttpInterceptor API relies on the IPC between the parent and the child processes to work. This is sufficient in some cases but there are scenarios when two processes cannot establish IPC even if they seemingly have the parent/child relationship (e.g. frameworks may spawn processes in a way that won't be associated with your test parent process).

In that regard, a WebSocker-based remote interception is a much more versatile solution. I've implemented a proof of concept for it in here:

I think it can be implemented in Interceptors instead, using a similar resolver/interceptor relationship as we have right now, just swapping the IPC mechanism with WebSocket events.

Keep in mind

Interceptors are more "transparent" than MSW, in the sense that Interceptors don't introduce A) request matching; B) request resolution layer. You can affect the request resolution via request.respondWith() but it's done on a per-request basis rather than a list of "handlers" like MSW has.

This means that the underlying implementation of this feature would differ slightly from the one I've prepared in MSW (i.e. cannot "await" remote handlers before running the direct ones). This most likely implies that the .untilIdle() promises we have on request listener calls would have to stretch outside to await the request listeners being called in a remote process (basically, awaiting a WS event that indicates that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant