Repository navigation
handle response body error - #369
Conversation
| import * as core from '@actions/core' | ||
|
|
||
| /** | ||
| * Internal class for retries |
There was a problem hiding this comment.
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.
Thoughts on using pipeline? It can be promisified, and deals with errors from all streams
There was a problem hiding this comment.
will look into switching over to that
There was a problem hiding this comment.
that is waaaaay better
thanks!
| if (!succeeded) { | ||
| core.debug('download failed') | ||
| try { | ||
| await io.rmRF(dest) |
There was a problem hiding this comment.
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.
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.
A module method to pipe between streams and generators forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.
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