Skip to content

Commit 8d66f61

Browse files
committed
fix: only invoke callback when it is defined
1 parent 2cdcc21 commit 8d66f61

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/unit/cmap/connection.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class FakeSocket extends EventEmitter {
4040
end(cb) {
4141
this.writableEnded = true;
4242
// nextTick to simulate I/O delay
43-
process.nextTick(cb);
43+
if (typeof cb === 'function') {
44+
process.nextTick(cb);
45+
}
4446
}
4547
get remoteAddress() {
4648
return 'iLoveJavaScript';
@@ -58,7 +60,9 @@ class InputStream extends Readable {
5860

5961
end(cb) {
6062
this.writableEnded = true;
61-
process.nextTick(cb);
63+
if (typeof cb === 'function') {
64+
process.nextTick(cb);
65+
}
6266
}
6367
}
6468

0 commit comments

Comments
 (0)