@@ -9,7 +9,6 @@ const lz4 = require('lz4js')
9
9
import { SQLiteCloudConfig , SQLCloudRowsetMetadata , SQLiteCloudError , SQLiteCloudDataTypes , ErrorCallback , ResultsCallback } from './types'
10
10
import { SQLiteCloudRowset } from './rowset'
11
11
import { parseConnectionString , parseBoolean } from './utilities'
12
- import { Socket } from 'net'
13
12
14
13
/**
15
14
* The server communicates with clients via commands defined
@@ -163,9 +162,9 @@ export class SQLiteCloudConnection {
163
162
this . socket . removeAllListeners ( 'data' )
164
163
this . socket . removeAllListeners ( 'error' )
165
164
this . socket . removeAllListeners ( 'close' )
166
- }
167
- if ( error ) {
168
- this . close ( )
165
+ if ( error ) {
166
+ this . close ( )
167
+ }
169
168
}
170
169
done ( error )
171
170
}
@@ -190,7 +189,7 @@ export class SQLiteCloudConnection {
190
189
console . assert ( this . socket , 'Connection already closed' )
191
190
const commands = this . initializationCommands
192
191
this . processCommands ( commands , error => {
193
- if ( error ) {
192
+ if ( error && this . socket ) {
194
193
this . close ( )
195
194
}
196
195
if ( callback ) {
@@ -357,7 +356,7 @@ export class SQLiteCloudConnection {
357
356
358
357
/** Disconnect from server, release connection. */
359
358
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' )
361
360
if ( this . socket ) {
362
361
this . socket . destroy ( )
363
362
this . socket = null
0 commit comments