mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

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

Closed kettanaito closed 2 weeks ago

kettanaito commented 2 weeks ago

Roadmap

robbtraister commented 2 weeks ago

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 commented 2 weeks ago

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

robbtraister commented 2 weeks ago

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

pkg-pr-new[bot] commented 2 weeks ago

Open in Stackblitz

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

commit: f70825d

kettanaito commented 2 weeks ago

@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 commented 2 weeks ago

@kettanaito it works for me! 🎉

patricklafrance commented 2 weeks ago

@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 commented 2 weeks ago

@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.

patricklafrance commented 2 weeks ago

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

kettanaito commented 2 weeks ago

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 commented 2 weeks ago

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

patricklafrance commented 2 weeks ago

@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 commented 2 weeks ago

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.