-
-
Notifications
You must be signed in to change notification settings - Fork 664
perf: use less promises in extractBody #4458
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?
Conversation
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.
See my answer to your linked comment. |
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.
lgtm
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.
lgtm
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.
Pull Request Overview
This PR improves performance in the extractBody
function by reducing the use of async/await syntax in favor of explicit promise handling.
- Removes async/await from ReadableStream controller methods
- Converts async functions to return promises directly using
.then()
- Simplifies promise handling in iterator operations
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
async cancel (reason) { | ||
await iterator.return() | ||
cancel (reason) { | ||
return iterator.return() |
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.
The iterator.return()
call may not exist on all iterators, as it's an optional method in the async iterator protocol. This could cause a runtime error if the iterator doesn't implement the return method. Consider checking if the method exists before calling it: return iterator.return?.() || Promise.resolve()
.
return iterator.return() | |
return iterator.return?.() || Promise.resolve() |
Copilot uses AI. Check for mistakes.
This relates to...
Rationale
Changes
Features
Bug Fixes
Breaking Changes and Deprecations
Status