Skip to content

Commit 2cfc907

Browse files
authored
Merge pull request #255 from sqlitecloud/fix-connection-ws-scaled-down-proj-error
2 parents e56ed2d + 7bedae1 commit 2cfc907

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqlitecloud/drivers",
3-
"version": "1.0.626",
3+
"version": "1.0.653",
44
"description": "SQLiteCloud drivers for Typescript/Javascript in edge, web and node clients",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

src/drivers/connection-ws.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,28 @@ export class SQLiteCloudWebsocketConnection extends SQLiteCloudConnection {
3232
const connectionstring = this.config.connectionstring as string
3333
const gatewayUrl = this.config?.gatewayurl || `${this.config.host === 'localhost' ? 'ws' : 'wss'}://${this.config.host as string}:4000`
3434
this.socket = io(gatewayUrl, { auth: { token: connectionstring } })
35-
35+
3636
this.socket.on('connect', () => {
3737
callback?.call(this, null)
3838
})
3939

40-
this.socket.on('disconnect', (reason) => {
40+
this.socket.on('disconnect', reason => {
4141
this.close()
4242
callback?.call(this, new SQLiteCloudError('Disconnected', { errorCode: 'ERR_CONNECTION_ENDED', cause: reason }))
4343
})
4444

45+
this.socket.on('connect_error', (error: any) => {
46+
this.close()
47+
callback?.call(
48+
this,
49+
new SQLiteCloudError(JSON.parse(error.context.responseText).message || 'Connection error', { errorCode: 'ERR_CONNECTION_ERROR' })
50+
)
51+
})
52+
4553
this.socket.on('error', (error: Error) => {
4654
this.close()
4755
callback?.call(this, new SQLiteCloudError('Connection error', { errorCode: 'ERR_CONNECTION_ERROR', cause: error }))
48-
})
56+
})
4957
}
5058
} catch (error) {
5159
callback?.call(this, error as Error)

0 commit comments

Comments
 (0)