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

chore: less async await #2464

Closed
wants to merge 4 commits into from
Closed

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Nov 27, 2023

Reopening #2463 for a better discussion ;).

This relates to...

Rationale

Changes

Features

Bug Fixes

Breaking Changes and Deprecations

Status

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

Attention: 62 lines in your changes are missing coverage. Please review.

Comparison is base (e39a632) 85.54% compared to head (663e2a7) 85.62%.
Report is 111 commits behind head on main.

Files Patch % Lines
lib/handler/RetryHandler.js 73.04% 31 Missing ⚠️
lib/fetch/index.js 66.66% 11 Missing ⚠️
lib/api/readable.js 73.91% 6 Missing ⚠️
lib/fetch/headers.js 87.80% 5 Missing ⚠️
lib/client.js 92.10% 3 Missing ⚠️
lib/core/util.js 90.47% 2 Missing ⚠️
lib/fetch/request.js 86.66% 2 Missing ⚠️
lib/core/request.js 97.56% 1 Missing ⚠️
lib/proxy-agent.js 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2464      +/-   ##
==========================================
+ Coverage   85.54%   85.62%   +0.07%     
==========================================
  Files          76       77       +1     
  Lines        6858     7053     +195     
==========================================
+ Hits         5867     6039     +172     
- Misses        991     1014      +23     

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

lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
@@ -82,40 +82,38 @@ class ProxyAgent extends DispatcherBase {
this[kClient] = clientFactory(resolvedUrl, { connect })
this[kAgent] = new Agent({
...opts,
connect: async (opts, callback) => {
connect: (opts, callback) => {
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 this is unnecessary change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh. This is for discussing. I agree this is reducing the maintainability. I am unsure if we save one Promise by this.

lib/proxy-agent.js Outdated Show resolved Hide resolved
lib/proxy-agent.js Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

Except for the connect case I don't mind the changes per se. I just don't think this will make any difference whatsoever in real world application. Maybe the consume change might have some value in terms of performance.

@ronag
Copy link
Member

ronag commented Nov 27, 2023

In general I'm starting to see a lot of PR's now that are trying to optimize cold paths, which IMHO is a waste of everyones time.

Co-authored-by: Toni Villena <tonivj5@Gmail.com>
Comment on lines +237 to +238
cancel (reason) {
return iterator.return()
Copy link
Member

Choose a reason for hiding this comment

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

This might hide it from the stacktrace, not sure the attempt is to keep that function hidden as is part of the RedeableStream API and can be helpful while debugging.

@@ -1807,11 +1807,11 @@ async function httpNetworkFetch (
async start (controller) {
fetchParams.controller.controller = controller
},
async pull (controller) {
await pullAlgorithm(controller)
pull (controller) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

the streams spec will wrap this in a promise, so it does nothing

@KhafraDev KhafraDev mentioned this pull request Nov 27, 2023
7 tasks
Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

I've changed my mind, I just had to track down an error that was caused by similar changes. For example, if something synchronously throws an error, it can now get swallowed - this is what happened in #2482. It's super annoying to debug and makes more work for us.

@Uzlopak Uzlopak closed this Dec 7, 2023
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.

7 participants