Skip to content

Commit d1fa59f

Browse files
mscdexaddaleax
authored andcommitted
child_process: simplify send() result handling
PR-URL: #13459 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent f134c9d commit d1fa59f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/internal/child_process.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,15 @@ function setupChannel(target, channel) {
645645
obj.postSend(handle, options, target);
646646
}
647647

648-
req.oncomplete = function() {
649-
if (this.async === true)
648+
if (req.async) {
649+
req.oncomplete = function() {
650650
control.unref();
651-
if (typeof callback === 'function')
652-
callback(null);
653-
};
654-
if (req.async === true) {
651+
if (typeof callback === 'function')
652+
callback(null);
653+
};
655654
control.ref();
656-
} else {
657-
process.nextTick(function() { req.oncomplete(); });
655+
} else if (typeof callback === 'function') {
656+
process.nextTick(callback, null);
658657
}
659658
} else {
660659
// Cleanup handle on error

0 commit comments

Comments
 (0)