File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,11 @@ Cursor.prototype.end = function (cb) {
149
149
150
150
Cursor . prototype . close = function ( cb ) {
151
151
if ( this . state === 'done' ) {
152
- return setImmediate ( cb )
152
+ if ( cb ) {
153
+ return setImmediate ( cb )
154
+ } else {
155
+ return
156
+ }
153
157
}
154
158
this . connection . close ( { type : 'P' } )
155
159
this . connection . sync ( )
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ describe('close', function () {
10
10
client . on ( 'drain' , client . end . bind ( client ) )
11
11
} )
12
12
13
+ it ( 'can close a finished cursor without a callback' , function ( done ) {
14
+ var cursor = new Cursor ( text )
15
+ this . client . query ( cursor )
16
+ this . client . query ( 'SELECT NOW()' , done )
17
+ cursor . read ( 100 , function ( err , res ) {
18
+ assert . ifError ( err )
19
+ cursor . close ( )
20
+ } )
21
+ } )
22
+
13
23
it ( 'closes cursor early' , function ( done ) {
14
24
var cursor = new Cursor ( text )
15
25
this . client . query ( cursor )
You can’t perform that action at this time.
0 commit comments