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 uncaught error in async middleware #135

Merged
merged 6 commits into from
May 23, 2021

Conversation

hoangvvo
Copy link

@hoangvvo hoangvvo commented May 8, 2020

I turned loop into an async function to allow it to be caught in next. I attempted to test out the performance implication by this change to async. This was run on node v12.16.3 and shows no significant difference but there may be for older versions that I did not get to.

hey -z 10s -m GET http://localhost:3000/user/123
// run 3 times, take the last one

this pr:

Summary:
  Total:	10.0018 secs
  Slowest:	0.0122 secs
  Fastest:	0.0001 secs
  Average:	0.0016 secs
  Requests/sec:	30993.6104
  
  Total data:	2789919 bytes
  Size/request:	9 bytes

polka/next:

Summary:
  Total:	10.0018 secs
  Slowest:	0.0116 secs
  Fastest:	0.0001 secs
  Average:	0.0016 secs
  Requests/sec:	30834.5827
  
  Total data:	2775618 bytes
  Size/request:	9 bytes

Closes #134
Closes #164

@kinsi55
Copy link

kinsi55 commented May 17, 2020

How many middlewares / handlers did you have when testing? Surely having like 5-10 would cause a significant difference

@hoangvvo
Copy link
Author

hoangvvo commented May 22, 2020

How many middlewares / handlers did you have when testing? Surely having like 5-10 would cause a significant difference

I used the one from bench/polka. Still, I think it will only be when there are about somewhat >50 or >30 that there is a significant diff.

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2021

Codecov Report

Merging #135 (2d3dbc1) into next (66f9cc5) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              next      #135   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          108       105    -3     
=========================================
- Hits           108       105    -3     
Impacted Files Coverage Δ
packages/polka/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66f9cc5...2d3dbc1. Read the comment docs.

Copy link
Owner

@lukeed lukeed left a comment

Choose a reason for hiding this comment

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

Thank you @hoangvvo! Sorry for the (massive) delay on this.

Confirmed that on my machine, at least with Node 14.15.3, that both this PR and the current next run at 37.2k and 37.3k req/sec.

This does require Node 8.x, which is technically breaking, but that's what next is for :)

@lukeed lukeed merged commit c677efc into lukeed:next May 23, 2021
lukeed added a commit that referenced this pull request May 23, 2021
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.

4 participants