diff --git a/lib/build/builder.ts b/lib/build/builder.ts index cea3cef..3c0984d 100644 --- a/lib/build/builder.ts +++ b/lib/build/builder.ts @@ -24,7 +24,6 @@ import * as fs from 'mz/fs'; import * as path from 'path'; import { Duplex } from 'stream'; import * as tar from 'tar-stream'; -import type * as http from 'http'; // Import hook definitions import * as Plugin from './plugin'; @@ -84,7 +83,6 @@ export default class Builder { const failBuild = _.once((err: Error) => { streamError = err; dup.destroy(err); - cleanupDaemonStream?.(); return this.callHook( hooks, 'buildFailure', @@ -98,8 +96,6 @@ export default class Builder { inputStream.on('error', failBuild); dup.on('error', failBuild); - let cleanupDaemonStream: (() => void) | undefined; - const buildPromise = (async () => { const daemonStream = await this.docker.buildImage(inputStream, buildOpts); @@ -109,27 +105,10 @@ export default class Builder { layers, fromTags, (err) => { - cleanupDaemonStream = () => { - if ( - 'req' in daemonStream! && - daemonStream.req != null && - typeof daemonStream.req === 'object' && - 'destroy' in daemonStream.req && - typeof daemonStream.req.destroy === 'function' - ) { - const req = daemonStream.req as http.ClientRequest; - if (!req.destroyed) { - req.destroy(); - } - } - daemonStream.unpipe(); - cleanupDaemonStream = undefined; - }; reject(err); }, ); outputStream.on('error', (error: Error) => { - daemonStream.unpipe(); reject(error); }); outputStream.on('end', () => @@ -144,7 +123,7 @@ export default class Builder { // It is helpful for the following promises to run in parallel because // buildPromise may reject sooner than the buildStream hook completes - // (in which case the stream is unpipe'd and destroy'ed), and yet the + // (in which case the stream is destroy'ed), and yet the // buildStream hook must be called in order for buildPromise to ever // resolve (as the hook call consumes the `dup` stream). Promise.all([