File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 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) {
175175
176176Cursor . prototype . close = function ( cb ) {
177177 if ( this . state === 'done' ) {
178- return setImmediate ( cb )
178+ if ( cb ) {
179+ return setImmediate ( cb )
180+ } else {
181+ return
182+ }
179183 }
180184 this . _closePortal ( )
181185 this . state = 'done'
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ describe('close', function() {
1010 client . on ( 'drain' , client . end . bind ( client ) )
1111 } )
1212
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+
1323 it ( 'closes cursor early' , function ( done ) {
1424 const cursor = new Cursor ( text )
1525 this . client . query ( cursor )
You can’t perform that action at this time.
0 commit comments