Skip to content

Commit 42e655a

Browse files
committed
process: fix output truncated
Fixes: #61337
1 parent 01ff6ce commit 42e655a

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

lib/internal/process/execution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function runScriptInContext(name, body, breakFirstLine, print, module, baseUrl,
455455
if (print) {
456456
const { log } = require('internal/console/global');
457457

458-
process.on('exit', () => {
458+
process.once('beforeExit', () => {
459459
log(result);
460460
});
461461
}

test/parallel/test-cli-eval.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "\\-42"`, common.
115115
assert.strictEqual(stderr, '');
116116
}));
117117

118+
// Long output should not be truncated.
119+
child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "'1'.repeat(1e5)"`, common.mustSucceed((stdout, stderr) => {
120+
assert.strictEqual(stdout, `${'1'.repeat(1e5)}\n`);
121+
assert.strictEqual(stderr, '');
122+
}));
123+
118124
child.exec(...common.escapePOSIXShell`"${process.execPath}" --use-strict -p process.execArgv`,
119125
common.mustSucceed((stdout, stderr) => {
120126
assert.strictEqual(

test/parallel/test-cli-print-promise.mjs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ describe('--print with a promise', { concurrency: !process.env.TEST_PARALLEL },
4747
});
4848
});
4949

50-
it('should output something if process exits before promise settles', async () => {
51-
const result = await spawnPromisified(execPath, [
52-
'--print',
53-
'setTimeout(process.exit, 100, 0);timers.promises.setTimeout(200)',
54-
]);
55-
56-
assert.deepStrictEqual(result, {
57-
code: 0,
58-
signal: null,
59-
stderr: '',
60-
stdout: 'Promise { <pending> }\n',
61-
});
62-
});
63-
6450
it('should respect exit code when process exits before promise settles', async () => {
6551
const result = await spawnPromisified(execPath, [
6652
'--print',
@@ -71,7 +57,7 @@ describe('--print with a promise', { concurrency: !process.env.TEST_PARALLEL },
7157
code: 42,
7258
signal: null,
7359
stderr: '',
74-
stdout: 'Promise { <pending> }\n',
60+
stdout: '',
7561
});
7662
});
7763

0 commit comments

Comments
 (0)