-
Notifications
You must be signed in to change notification settings - Fork 550
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(api-stream): Add throwOnError support in undici.stream #1767
fix(api-stream): Add throwOnError support in undici.stream #1767
Conversation
This doesn't handle body properly, see differences between await undici.request('https://api.github.com/notfound', {
throwOnError: true
})
await undici.stream(
"https://api.github.com/notfound",
{ throwOnError: true },
() => fs.createWriteStream("response.txt")
);
|
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.
good work, can you add docs?
Hi @mdashlw, thank you for your comment. |
Hi @mcollina, thank you 🙏🏼. |
8f7a6d7 kind of re-introduces the entire issue. await undici.stream(
"https://api.github.com",
{ throwOnError: true },
() => fs.createWriteStream("response.txt")
);
IMO the most intuitive and convenient way would be to throw an error with special body handling, as in |
test/client-stream.js
Outdated
method: 'GET', | ||
throwOnError: true, | ||
opaque: passThrough | ||
}, ({ opaque }) => opaque) |
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.
I would not expect this factory to be called at all.
Since in @mdashlw for the body handling in |
You can consume the body without calling the factory. |
I updated the logic, to throw before calling the factory, and I handled the body so the thrown error contains it. I updated the tests accordingly. I hope that is the behavior we expect. |
Codecov ReportBase: 90.28% // Head: 90.24% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1767 +/- ##
==========================================
- Coverage 90.28% 90.24% -0.04%
==========================================
Files 58 58
Lines 5188 5199 +11
==========================================
+ Hits 4684 4692 +8
- Misses 504 507 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Hi @mcollina, can you review the changes please? 😊 |
there are ci failures caused by a node-fetch test ( |
This will be fixed once we move |
#1753