Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Jan 5, 2025
1 parent 5ac939c commit de200d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/internal/worker/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class WritableWorkerStdio extends Writable {
({ chunk, encoding }) => ({ chunk, encoding })),
});
if (process._exiting) {
cb()
cb();
} else {
ArrayPrototypePush(this[kWritableCallbacks], cb);
if (this[kPort][kWaitingStreams]++ === 0)
Expand Down
23 changes: 10 additions & 13 deletions test/parallel/test-worker-stdio-flush-inflight.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const util = require('util');
const { Writable } = require('stream');
const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
const w = new Worker(__filename, { stdout: true });
const expected = 'hello world'
const expected = 'hello world';

let data = ''
w.stdout.setEncoding('utf8')
let data = '';
w.stdout.setEncoding('utf8');
w.stdout.on('data', (chunk) => {
data += chunk
})
data += chunk;
});

w.on('exit', common.mustCall(() => {
assert.strictEqual(data, expected)
assert.strictEqual(data, expected);
}));
} else {
process.stdout.write('hello')
process.stdout.write(' ')
process.stdout.write('world')
process.exit(0)
process.stdout.write('hello');
process.stdout.write(' ');
process.stdout.write('world');
process.exit(0);
}
23 changes: 10 additions & 13 deletions test/parallel/test-worker-stdio-flush.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const util = require('util');
const { Writable } = require('stream');
const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
const w = new Worker(__filename, { stdout: true });
const expected = 'hello world'
const expected = 'hello world';

let data = ''
w.stdout.setEncoding('utf8')
let data = '';
w.stdout.setEncoding('utf8');
w.stdout.on('data', (chunk) => {
data += chunk
})
data += chunk;
});

w.on('exit', common.mustCall(() => {
assert.strictEqual(data, expected)
assert.strictEqual(data, expected);
}));
} else {
process.on('exit', () => {
process.stdout.write(' ')
process.stdout.write('world')
})
process.stdout.write('hello')
process.stdout.write(' ');
process.stdout.write('world');
});
process.stdout.write('hello');
}

0 comments on commit de200d8

Please sign in to comment.