@@ -9,7 +9,6 @@ const lz4 = require('lz4js')
99import { SQLiteCloudConfig , SQLCloudRowsetMetadata , SQLiteCloudError , SQLiteCloudDataTypes , ErrorCallback , ResultsCallback } from './types'
1010import { SQLiteCloudRowset } from './rowset'
1111import { parseConnectionString , parseBoolean } from './utilities'
12- import { Socket } from 'net'
1312
1413/**
1514 * The server communicates with clients via commands defined
@@ -163,9 +162,9 @@ export class SQLiteCloudConnection {
163162 this . socket . removeAllListeners ( 'data' )
164163 this . socket . removeAllListeners ( 'error' )
165164 this . socket . removeAllListeners ( 'close' )
166- }
167- if ( error ) {
168- this . close ( )
165+ if ( error ) {
166+ this . close ( )
167+ }
169168 }
170169 done ( error )
171170 }
@@ -190,7 +189,7 @@ export class SQLiteCloudConnection {
190189 console . assert ( this . socket , 'Connection already closed' )
191190 const commands = this . initializationCommands
192191 this . processCommands ( commands , error => {
193- if ( error ) {
192+ if ( error && this . socket ) {
194193 this . close ( )
195194 }
196195 if ( callback ) {
@@ -357,7 +356,7 @@ export class SQLiteCloudConnection {
357356
358357 /** Disconnect from server, release connection. */
359358 public close ( ) : this {
360- console . assert ( this . socket !== undefined , 'SQLiteCloudConnection.close - connection already closed' )
359+ console . assert ( this . socket !== null , 'SQLiteCloudConnection.close - connection already closed' )
361360 if ( this . socket ) {
362361 this . socket . destroy ( )
363362 this . socket = null
0 commit comments