Mark job as failed on error (#14)

* fix: set failed on subprocess error

* chore: update dependencies
This commit is contained in:
Andrei Ioniță 2021-06-20 08:35:43 +01:00 committed by GitHub
commit 9eab20634f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 281 additions and 1118 deletions

23
node_modules/get-stream/index.js generated vendored
View file

@ -1,8 +1,11 @@
'use strict';
const {constants: BufferConstants} = require('buffer');
const pump = require('pump');
const stream = require('stream');
const {promisify} = require('util');
const bufferStream = require('./buffer-stream');
const streamPipelinePromisified = promisify(stream.pipeline);
class MaxBufferError extends Error {
constructor() {
super('maxBuffer exceeded');
@ -12,7 +15,7 @@ class MaxBufferError extends Error {
async function getStream(inputStream, options) {
if (!inputStream) {
return Promise.reject(new Error('Expected a stream'));
throw new Error('Expected a stream');
}
options = {
@ -21,8 +24,8 @@ async function getStream(inputStream, options) {
};
const {maxBuffer} = options;
const stream = bufferStream(options);
let stream;
await new Promise((resolve, reject) => {
const rejectPromise = error => {
// Don't retrieve an oversized buffer.
@ -33,14 +36,14 @@ async function getStream(inputStream, options) {
reject(error);
};
stream = pump(inputStream, bufferStream(options), error => {
if (error) {
(async () => {
try {
await streamPipelinePromisified(inputStream, stream);
resolve();
} catch (error) {
rejectPromise(error);
return;
}
resolve();
});
})();
stream.on('data', () => {
if (stream.getBufferedLength() > maxBuffer) {
@ -53,8 +56,6 @@ async function getStream(inputStream, options) {
}
module.exports = getStream;
// TODO: Remove this for the next major release
module.exports.default = getStream;
module.exports.buffer = (stream, options) => getStream(stream, {...options, encoding: 'buffer'});
module.exports.array = (stream, options) => getStream(stream, {...options, array: true});
module.exports.MaxBufferError = MaxBufferError;