Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ytoshiki
Copy link
Contributor

@ytoshiki ytoshiki commented Apr 11, 2025

Description

  • Mark the request handler as used only after its resolver function has returned a response.

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.

@@ -325,6 +325,7 @@ export abstract class RequestHandler<
if (!this.resolverIterator) {
const result = await resolver(info)
if (!isIterable(result)) {
this.isUsed = result instanceof Response
Copy link
Contributor Author

@ytoshiki ytoshiki Apr 11, 2025

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.

this.isUsed = true

Please let me know if you have any suggestions or thoughts on this.

@ytoshiki ytoshiki marked this pull request as ready for review April 11, 2025 16:45
@kettanaito
Copy link
Member

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.

@ytoshiki
Copy link
Contributor Author

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
Thank you for your response.
No problem at all — I completely understand. I appreciate you taking the time.

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

Successfully merging this pull request may close these issues.

Do not exhaust one-time handlers with custom predicate in resolver
2 participants