-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
handle response body error #369
Conversation
import * as core from '@actions/core' | ||
|
||
/** | ||
* Internal class for retries |
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.
Private for now. If expose a class for consumers we probably want to put more thought into the interface and behaviors. And probably do exponent backoff in that case.
() => response.message | ||
) | ||
const readStream = responseMessageFactory() | ||
readStream.pipe(file) |
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.
Thoughts on using pipeline
? It can be promisified, and deals with errors from all streams
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.
will look into switching over to that
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.
that is waaaaay better
thanks!
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.
great! 👍
if (!succeeded) { | ||
core.debug('download failed') | ||
try { | ||
await io.rmRF(dest) |
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.
if we can't delete the dest
on error, then the next retry will just error with Destination file path ${dest} already exists
.
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.
it shouldnt happen. If so then a bug we need to figure out.
const readStream = responseMessageFactory() | ||
let succeeded = false | ||
try { | ||
await pipeline(readStream, fs.createWriteStream(dest)) |
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.
A module method to pipe between streams and generators forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.
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
aeb718e
to
7d54cbf
Compare
7d54cbf
to
eab6335
Compare
Update tool-cache downloadTool() to handle errors from response body stream
related to actions/setup-node#116