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

fix: prevent instanceof handler check failures between different MSW versions #2349

Merged
merged 6 commits into from
Nov 6, 2024

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Nov 6, 2024

Roadmap

  • Use the same pattern for filtering WebSocket handlers (ref).

@kettanaito kettanaito marked this pull request as ready for review November 6, 2024 15:06
@robbtraister
Copy link
Contributor

do you also want to use this pattern for filtering the websocket handlers?

https://github.com/mswjs/msw/blob/main/src/core/ws/handleWebSocketEvent.ts#L33

@kettanaito
Copy link
Member Author

@robbtraister, thanks, that's a fantastic point. Will adjust the solution.

@robbtraister
Copy link
Contributor

this is awesome! I really appreciate the effort on this.

Copy link

pkg-pr-new bot commented Nov 6, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/msw@2349

commit: f70825d

@kettanaito
Copy link
Member Author

@patricklafrance @robbtraister can you please give this preview release a try and let me know if the issue is fixed on your end? I would publish the changes then. Thanks.

@robbtraister
Copy link
Contributor

@kettanaito it works for me! 🎉

@patricklafrance
Copy link

@kettanaito I am not sure what's going on, I'll have to investigate but at the moment NO requests at all are being intercepted, not even those for the HOST app request handlers.

The issue might be on on my side though, I'll have to investigate later today.

@kettanaito
Copy link
Member Author

@patricklafrance, you mentioned you have different frontends loading different versions of MSW. If that's the case, none of the older versions will include __kind in their handlers, so this change will still ignore them.

I highly encourage you to update MSW across the board. I presume you are at v2 already so it should be a breeze.

@kettanaito kettanaito merged commit 28d26bd into main Nov 6, 2024
14 checks passed
@kettanaito kettanaito deleted the fix/handler-instanceof-check branch November 6, 2024 20:31
@patricklafrance
Copy link

patricklafrance commented Nov 6, 2024

@kettanaito they are all on the same version in my sample application that I used for testing this new version.

@kettanaito
Copy link
Member Author

Released: v2.6.1 🎉

This has been released in v2.6.1!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

@kettanaito
Copy link
Member Author

Oh, that's interesting! Is that reproducible in the example you shared with me?

@patricklafrance
Copy link

patricklafrance commented Nov 7, 2024

@kettanaito I think it was something about how I installed the PR package (https://pkg.pr.new/msw@2349). Not sure what happened but i tried with 2.6.1 and everything works fine. So happy, thank you very much for the quick fix :)

@patricklafrance
Copy link

Oh, that's interesting! Is that reproducible in the example you shared with me?

It's fixed with 2.6.1 but yes it was reproducible with the example I shared with you. This is the one I used.

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

Successfully merging this pull request may close these issues.

Interception broken due to instanceof handlers check (dual publish)
3 participants