diff --git a/package-lock.json b/package-lock.json index da90c72..d2b73bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "domcloud-bridge", - "version": "0.56.0", + "version": "0.56.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "domcloud-bridge", - "version": "0.56.0", + "version": "0.56.1", "license": "MIT", "dependencies": { "cli": "^1.0.1", diff --git a/package.json b/package.json index 3c92c8f..8d0504a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domcloud-bridge", - "version": "0.56.0", + "version": "0.56.1", "description": "Deployment runner for DOM Cloud", "main": "app.js", "engines": { diff --git a/src/controllers/runner.js b/src/controllers/runner.js index 82cca81..f768ec3 100644 --- a/src/controllers/runner.js +++ b/src/controllers/runner.js @@ -56,6 +56,7 @@ export async function runConfigInBackground(body, domain, sandbox, callback) { chunkedLogData = ['Running deployment script... Please wait...\n'], startTime = Date.now(); const write = new PassThrough(); + const delay = 5000; const headers = { 'Content-Type': 'text/plain; charset=UTF-8', }; @@ -79,6 +80,9 @@ export async function runConfigInBackground(body, domain, sandbox, callback) { console.error(e); }); } + if (write && !write.writableEnded) { + setTimeout(periodicSender, delay).unref(); + } } periodicSender(); write.on('data', (chunk) => { @@ -89,6 +93,7 @@ export async function runConfigInBackground(body, domain, sandbox, callback) { write.on('end', () => { // and finish message with full log if (callback) { + chunkedLogData = []; const data = trimPayload(normalizeShellOutput(fullLogData)); request(callback, { data, headers, ...options }) .then(e => { @@ -99,9 +104,9 @@ export async function runConfigInBackground(body, domain, sandbox, callback) { } }); try { - await runConfig(body || {}, domain + "", async (s) => { + await runConfig(body || {}, domain + "", (s) => { console.log('> ' + s); - await writeAsync(write, s); + return writeAsync(write, s); }, sandbox); } catch (error) { console.log('!> ', error);