Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[fixup]
  • Loading branch information
refack committed Jul 19, 2017
commit 71cb15378cc3d93ef6217a7e0066c58d4a7c9af2
5 changes: 5 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ by the `assert` module.

Used when attempting to perform an operation outside the bounds of a `Buffer`.

<a id="ERR_CHILD_CLOSED_BEFORE_REPLY"></a>
### ERR_CHILD_CLOSED_BEFORE_REPLY

Used when a child process is closed before the parent got a replay.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: replay -> reply

Micronit: got -> received


<a id="ERR_CONSOLE_WRITABLE_STREAM"></a>
### ERR_CONSOLE_WRITABLE_STREAM

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ module.exports = exports = {
E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');
E('ERR_ASSERTION', '%s');
E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds);
E('ERR_CHILD_CLOSED_BEFORE_REPLY','Child closed before reply received');
E('ERR_CONSOLE_WRITABLE_STREAM',
'Console expects a writable stream instance for %s');
E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s');
Expand Down Expand Up @@ -176,8 +177,7 @@ E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type');
E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type');
E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' +
'See https://github.com/nodejs/node/wiki/Intl');
// Add new errors from here...
E('ERR_SLAVE_CLOSED_BEFORE_REPLY','Slave closed before reply');


function invalidArgType(name, expected, actual) {
assert(name, 'name is required');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/socket_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SocketListSend extends EventEmitter {

function onclose() {
self.child.removeListener('internalMessage', onreply);
callback(new errors.Error('ERR_SLAVE_CLOSED_BEFORE_REPLY'));
callback(new errors.Error('ERR_CHILD_CLOSED_BEFORE_REPLY'));
}

function onreply(msg) {
Expand Down
22 changes: 17 additions & 5 deletions test/parallel/test-internal-socket-list-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const key = 'test-key';
const list = new SocketListSend(child, 'test');

list._request('msg', 'cmd', common.mustCall((err) => {
assert.strictEqual(err.message, 'child closed before reply');
common.expectsError({
code: 'ERR_CHILD_CLOSED_BEFORE_REPLY',
type: Error,
message: 'Child closed before reply received'
})(err);
assert.strictEqual(child.listenerCount('internalMessage'), 0);
}));
}
Expand Down Expand Up @@ -55,7 +59,11 @@ const key = 'test-key';
const list = new SocketListSend(child, key);

list._request('msg', 'cmd', common.mustCall((err) => {
assert.strictEqual(err.message, 'child closed before reply');
common.expectsError({
code: 'ERR_CHILD_CLOSED_BEFORE_REPLY',
type: Error,
message: 'Child closed before reply received'
})(err);
assert.strictEqual(child.listenerCount('internalMessage'), 0);
}));
}
Expand Down Expand Up @@ -119,7 +127,7 @@ const key = 'test-key';
const count = 1;
const child = Object.assign(new EventEmitter(), {
connected: true,
send: function(msg) {
send: function() {
process.nextTick(() => {
this.emit('disconnect');
this.emit('internalMessage', { key, count, cmd: 'NODE_SOCKET_COUNT' });
Expand All @@ -129,8 +137,12 @@ const key = 'test-key';

const list = new SocketListSend(child, key);

list.getConnections(common.mustCall((err, msg) => {
assert.strictEqual(err.message, 'child closed before reply');
list.getConnections(common.mustCall((err) => {
common.expectsError({
code: 'ERR_CHILD_CLOSED_BEFORE_REPLY',
type: Error,
message: 'Child closed before reply received'
})(err);
assert.strictEqual(child.listenerCount('internalMessage'), 0);
}));
}