Skip to content

Commit

Permalink
Add a more useful error message when we cache a broken tarball (#3355)
Browse files Browse the repository at this point in the history
It looks like there should be an error handler that reports the
`fetchErrorCorrupt` string, but instead an error from tar-stream
is being returned without the filename.
  • Loading branch information
sandlerr authored and bestander committed May 9, 2017
1 parent 525ce9c commit 0f68486
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class TarballFetcher extends BaseFetcher {
createExtractor(
resolve: (fetched: FetchedOverride) => void,
reject: (error: Error) => void,
tarballPath?: string,
): {
validateStream: crypto.HashStream,
extractorStream: stream.Transform,
Expand All @@ -84,7 +85,10 @@ export default class TarballFetcher extends BaseFetcher {

extractorStream
.pipe(untarStream)
.on('error', reject)
.on('error', (error) => {
error.message = `${error.message}${tarballPath ? ` (${tarballPath})` : ''}`;
reject(error);
})
.on('finish', () => {
const expectHash = this.hash;
const actualHash = validateStream.getHash();
Expand Down Expand Up @@ -113,7 +117,7 @@ export default class TarballFetcher extends BaseFetcher {
}

return new Promise((resolve, reject) => {
const {validateStream, extractorStream} = this.createExtractor(resolve, reject);
const {validateStream, extractorStream} = this.createExtractor(resolve, reject, tarballPath);
const cachedStream = fs.createReadStream(tarballPath);

cachedStream
Expand Down

0 comments on commit 0f68486

Please sign in to comment.