Skip to content

Commit

Permalink
ULMS-2999 Make WS_ERROR recoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonst committed Apr 25, 2024
1 parent 7f8c348 commit 154d0f1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/api-clients",
"version": "7.4.1",
"version": "7.4.2",
"description": "JavaScript API clients for ULMS platform",
"keywords": [],
"homepage": "https://github.com/foxford/ulms-api-clients-js#readme",
Expand Down
26 changes: 2 additions & 24 deletions src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,12 @@ export class PresenceError extends Error {
this.name = 'PresenceError'
}

static get kinds() {
return {
RECOVERABLE_SESSION_ERROR: 'recoverable_session_error',
UNRECOVERABLE_SESSION_ERROR: 'unrecoverable_session_error',
}
}

static get recoverableTypes() {
return {
KEEP_ALIVE_TIMED_OUT: 'KEEP_ALIVE_TIMED_OUT', // client-side error
PING_TIMED_OUT: 'PING_TIMED_OUT', // client-side error // todo: remove it

// slow_subscriber -> slow_consumer
SLOW_SUBSCRIBER: 'SLOW_SUBSCRIBER', // todo: remove it
SLOW_CONSUMER: 'SLOW_CONSUMER',

// terminated -> server_shutdown
TERMINATED: 'TERMINATED', // todo: remove it
SERVER_SHUTDOWN: 'SERVER_SHUTDOWN',
SLOW_CONSUMER: 'SLOW_CONSUMER',
WS_ERROR: 'WS_ERROR', // client-side error
}
}

Expand All @@ -62,13 +49,10 @@ export class PresenceError extends Error {
INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
NOT_CONNECTED: 'NOT_CONNECTED', // client-side error

// replaced -> session_replaced
REPLACED: 'REPLACED', // todo: remove it
SESSION_REPLACED: 'SESSION_REPLACED',

SERIALIZATION_FAILED: 'SERIALIZATION_FAILED',
UNKNOWN_ERROR: 'UNKNOWN_ERROR', // client-side error
WS_ERROR: 'WS_ERROR', // client-side error

// currently unused and commented (todo: comment or remove)
CONNECT_TIMEOUT: 'CONNECT_TIMEOUT', // ✅
Expand All @@ -87,12 +71,6 @@ export class PresenceError extends Error {
return new PresenceError(errorType)
}

static isRecoverableSessionError(error) {
const { type } = error

return type === PresenceError.kinds.RECOVERABLE_SESSION_ERROR
}

static isReplacedError(error) {
if (!(error instanceof PresenceError)) return false

Expand Down
1 change: 1 addition & 0 deletions src/ws-transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const KEEP_ALIVE_TIMED_OUT_ERROR_PAYLOAD = {
}
const WS_CLOSED_ERROR_PAYLOAD = {
payload: {
is_transient: true,
title: 'Connection closed',
type: 'ws_error',
},
Expand Down

0 comments on commit 154d0f1

Please sign in to comment.