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(combine): halt middleware evaluation if error in next() #3905

Merged
merged 6 commits into from
Feb 9, 2025

Conversation

usualoma
Copy link
Member

@usualoma usualoma commented Feb 7, 2025

fixes #3898

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.28%. Comparing base (4203973) to head (033d48b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3905   +/-   ##
=======================================
  Coverage   91.27%   91.28%           
=======================================
  Files         168      168           
  Lines       10750    10757    +7     
  Branches     3164     3165    +1     
=======================================
+ Hits         9812     9819    +7     
  Misses        937      937           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@usualoma
Copy link
Member Author

usualoma commented Feb 7, 2025

Hi @satoshun00!
Thank you for the report and PR. Thanks to you, I understand the situation better.

The test code was used in the following commit.
964a1e1

I wonder if this will fix the problem.

@usualoma
Copy link
Member Author

usualoma commented Feb 7, 2025

Oh, I see, we also need to handle the case where true is returned, so I've added two more commits.

@satoshun00
Copy link
Contributor

@usualoma
Thank you for the quick response! I was also looking at this part of the code, and I think this approach makes sense.

One small point—since some() processes multiple middleware using a for-loop, it might be worth verifying in the test code that the call count for the next function is 1.

@usualoma
Copy link
Member Author

usualoma commented Feb 7, 2025

Hi @satoshun00
Thank you for your comment!
For the following reasons, I don't think it's necessary to add a test.

@usualoma
Copy link
Member Author

usualoma commented Feb 7, 2025

@yusukebe
Would you please review this?

continue
if (isNextCalled) {
break
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these lines #L61 - L62 are covered, though Codecov says they are not covered. Should you add more tests?

Copy link
Member Author

@usualoma usualoma Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comment.

The refactoring of the test in e0cf156 was not good😢 Fixed in 033d48b.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

continue
if (isNextCalled) {
break
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see!

@yusukebe
Copy link
Member

yusukebe commented Feb 9, 2025

@usualoma Thank you for the quick fix!

@satoshun00 Thank you for raising the issue!

@yusukebe yusukebe merged commit 6ceb1ab into honojs:main Feb 9, 2025
16 checks passed
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.

[hono/combine] Function skipped in some() inside every() is still called
3 participants