Skip to content

Commit

Permalink
test: add test for port stoppage. see nodejs/node#26463.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Mar 6, 2019
1 parent a80af15 commit 445514a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/threads-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ describe(`Threads (${threads.backend})`, (ctx) => {
thread.on('exit', onExit(cb, () => called, 0));
});

// https://github.com/nodejs/node/issues/26463
it('should not throw on unbind after close', () => {
const {port1, port2} = new threads.Channel();
const fn = () => {};
Expand All @@ -943,4 +944,33 @@ describe(`Threads (${threads.backend})`, (ctx) => {
port1.off('message', fn);
});
});

// https://github.com/nodejs/node/issues/26463
it.skip('should not buffer after onmessage removal', (cb) => {
const {port1, port2} = new threads.Channel();
const text = [];

port1.send('hello');

setTimeout(() => {
port2.on('message', (data) => {
text.push(data);

port2.removeAllListeners('message');
port1.send('world');

setTimeout(() => {
port2.on('message', (data) => {
text.push(data);
});

setTimeout(() => {
port2.removeAllListeners('message');
assert.strictEqual(text.join(' '), 'hello');
cb();
}, 100);
}, 100);
});
}, 100);
});
});

0 comments on commit 445514a

Please sign in to comment.