-
-
Notifications
You must be signed in to change notification settings - Fork 552
feat: do not exhaust one-time handlers with custom predicate in resolver #2472
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
base: main
Are you sure you want to change the base?
feat: do not exhaust one-time handlers with custom predicate in resolver #2472
Conversation
@@ -325,6 +325,7 @@ export abstract class RequestHandler< | |||
if (!this.resolverIterator) { | |||
const result = await resolver(info) | |||
if (!isIterable(result)) { | |||
this.isUsed = result instanceof Response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn’t able to apply the change in the run
method as you suggested, because we need to take generator use cases into consideration.
Also, I kept this line as is to ensure parallel processing works correctly.
msw/src/core/handlers/RequestHandler.ts
Line 280 in e3234fd
this.isUsed = true |
Please let me know if you have any suggestions or thoughts on this.
Hi, @ytoshiki. Thank you so much for submitting this. Please give me some time to think about the best direction here. Changes like this are pretty fundamental, and I don't have enough focus right now to be the best judge for them. I will share my thoughts on this once I have proper time to spend on this issue. My initial impression is that I vaguely recall that request handlers were considered used as soon as they matched, even if they didn't return a mocked response. This may or may not make sense in the present, just something I think I remember. |
@kettanaito |
Description
resolves #2399
Concern
There might be an edge case where a user's internal resolver doesn't return anything but still expects the request to be consumed only once.
I'm not sure how realistic this scenario is, but I thought it was worth mentioning.
Thank you.