resolve all pending rpc requests on gateway disconnect
This commit is contained in:
parent
fd8aa70ee2
commit
97e5bfbe5c
2 changed files with 14 additions and 10 deletions
|
@ -13,6 +13,16 @@ export const GatewayErrors = {
|
|||
TOO_MANY_SESSIONS: 4008,
|
||||
};
|
||||
|
||||
// this should be in request.js, but putting it here avoids a circular dependency
|
||||
export const RequestStatus = {
|
||||
OK: 0,
|
||||
NETWORK_EXCEPTION: 1,
|
||||
JSON_EXCEPTION: 2,
|
||||
FAILURE_STATUS: 3,
|
||||
RPC_ERROR: 4,
|
||||
INVARIANT_RPC_RESPONSE_COUNT: 5,
|
||||
};
|
||||
|
||||
export const GatewayPayloadType = {
|
||||
Hello: 0,
|
||||
Authenticate: 1, // client
|
||||
|
@ -148,6 +158,9 @@ export default {
|
|||
clearInterval(this.heartbeatInterval);
|
||||
}
|
||||
|
||||
this.waitingSerials.forEach((resolve) => resolve({ status: RequestStatus.NETWORK_EXCEPTION }));
|
||||
this.waitingSerials.clear();
|
||||
|
||||
if (code === GatewayErrors.BAD_AUTH) {
|
||||
this.dispatch(GatewayEventType.BadAuth, 1);
|
||||
if (this.reconnectTimeout)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import gateway from "./gateway";
|
||||
import gateway, { RequestStatus } from "./gateway";
|
||||
import { apiRoute, getItem } from "./storage";
|
||||
|
||||
const method = (methodId, requiresAuthentication) => ({methodId, requiresAuthentication});
|
||||
|
@ -43,15 +43,6 @@ export const RPCError = {
|
|||
INTERNAL_ERROR: { code: 7003, message: "Sorry, we couldn't process this request (internal server error)" },
|
||||
};
|
||||
|
||||
export const RequestStatus = {
|
||||
OK: 0,
|
||||
NETWORK_EXCEPTION: 1,
|
||||
JSON_EXCEPTION: 2,
|
||||
FAILURE_STATUS: 3,
|
||||
RPC_ERROR: 4,
|
||||
INVARIANT_RPC_RESPONSE_COUNT: 5,
|
||||
};
|
||||
|
||||
export const RequestStatusToMessage = {
|
||||
[RequestStatus.OK]: "",
|
||||
[RequestStatus.NETWORK_EXCEPTION]: "We couldn't reach the server right now",
|
||||
|
|
Loading…
Reference in a new issue