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 @@ -175,7 +175,11 @@ Cursor.prototype.end = util.deprecate(function(cb) {
175
175
176
176
Cursor . prototype . close = function ( cb ) {
177
177
if ( this . state === 'done' ) {
178
- return setImmediate ( cb )
178
+ if ( cb ) {
179
+ return setImmediate ( cb )
180
+ } else {
181
+ return
182
+ }
179
183
}
180
184
this . _closePortal ( )
181
185
this . state = 'done'
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
+ const cursor = new Cursor ( text )
15
+ this . client . query ( cursor )
16
+ this . client . query ( 'SELECT NOW()' , done )
17
+ cursor . read ( 100 , function ( err ) {
18
+ assert . ifError ( err )
19
+ cursor . close ( )
20
+ } )
21
+ } )
22
+
13
23
it ( 'closes cursor early' , function ( done ) {
14
24
const cursor = new Cursor ( text )
15
25
this . client . query ( cursor )
You can’t perform that action at this time.
0 commit comments