[price-service/client] Crash by default on WsError (#934)

* [price-service/client] Crash by default on WsError

* Update docker-compose files

* Update package versions again
This commit is contained in:
Ali Behjati 2023-07-07 11:43:04 +03:30 committed by GitHub
parent 4f41525a2f
commit bef4073b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 84 additions and 47 deletions

8
package-lock.json generated
View File

@ -55928,7 +55928,7 @@
}, },
"price_pusher": { "price_pusher": {
"name": "@pythnetwork/price-pusher", "name": "@pythnetwork/price-pusher",
"version": "5.4.3", "version": "5.4.4",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@injectivelabs/sdk-ts": "1.10.72", "@injectivelabs/sdk-ts": "1.10.72",
@ -57359,7 +57359,7 @@
}, },
"price_service/client/js": { "price_service/client/js": {
"name": "@pythnetwork/price-service-client", "name": "@pythnetwork/price-service-client",
"version": "1.6.0", "version": "1.6.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@pythnetwork/price-service-sdk": "*", "@pythnetwork/price-service-sdk": "*",
@ -57976,7 +57976,7 @@
}, },
"target_chains/cosmwasm/sdk/js": { "target_chains/cosmwasm/sdk/js": {
"name": "@pythnetwork/pyth-terra-js", "name": "@pythnetwork/pyth-terra-js",
"version": "1.3.0", "version": "1.3.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@pythnetwork/price-service-client": "*", "@pythnetwork/price-service-client": "*",
@ -59019,7 +59019,7 @@
}, },
"target_chains/ethereum/sdk/js": { "target_chains/ethereum/sdk/js": {
"name": "@pythnetwork/pyth-evm-js", "name": "@pythnetwork/pyth-evm-js",
"version": "1.20.0", "version": "1.20.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@pythnetwork/price-service-client": "*", "@pythnetwork/price-service-client": "*",

View File

@ -1,7 +1,7 @@
services: services:
spy: spy:
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
image: ghcr.io/wormhole-foundation/guardiand:v2.17.0 image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
command: command:
- "spy" - "spy"
- "--nodeKey" - "--nodeKey"
@ -16,7 +16,7 @@ services:
- "warn" - "warn"
price-service: price-service:
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
image: public.ecr.aws/pyth-network/xc-server:v3.0.3 image: public.ecr.aws/pyth-network/xc-server:v3.0.8
environment: environment:
SPY_SERVICE_HOST: "spy:7072" SPY_SERVICE_HOST: "spy:7072"
SPY_SERVICE_FILTERS: | SPY_SERVICE_FILTERS: |
@ -32,8 +32,8 @@ services:
] ]
REST_PORT: "4200" REST_PORT: "4200"
PROM_PORT: "8081" PROM_PORT: "8081"
READINESS_SPY_SYNC_TIME_SECONDS: "20" READINESS_SPY_SYNC_TIME_SECONDS: "5"
READINESS_NUM_LOADED_SYMBOLS: "50" READINESS_NUM_LOADED_SYMBOLS: "280"
LOG_LEVEL: warning LOG_LEVEL: warning
WORMHOLE_CLUSTER: mainnet WORMHOLE_CLUSTER: mainnet
healthcheck: healthcheck:
@ -50,12 +50,20 @@ services:
depends_on: depends_on:
- spy - spy
price-pusher: price-pusher:
build: # Use this to build the price pusher from source. A dependency of the pusher docker
context: . # image is the pyth-crosschain monorepo lerna docker image. Build lerna image
# Uncomment this line (and comment out the above lines) to use a prebuilt image. Replace <version> # using the following command from the repo root:
# with the latest released image of the price pusher from this repo release page: # `docker buildx build -f tilt_devnet/docker_images/Dockerfile.lerna -t lerna .`
# https://github.com/pyth-network/pyth-crosschain/releases #
# image: public.ecr.aws/pyth-network/xc-price-pusher:v<version> # Please note that the docker build from source only works in x86_64 platforms
# and doesn't work on arm platforms (like Apple M1/M2).
#
# build:
# context: .
# Replace <version> with the latest released image of the price pusher from here:
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
restart: always restart: always
command: command:
- "--" - "--"

View File

@ -1,7 +1,7 @@
services: services:
spy: spy:
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
image: ghcr.io/wormhole-foundation/guardiand:v2.17.0 image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
command: command:
- "spy" - "spy"
- "--nodeKey" - "--nodeKey"
@ -16,7 +16,7 @@ services:
- "warn" - "warn"
price-service: price-service:
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
image: public.ecr.aws/pyth-network/xc-server:v3.0.3 image: public.ecr.aws/pyth-network/xc-server:v3.0.8
environment: environment:
SPY_SERVICE_HOST: "spy:7072" SPY_SERVICE_HOST: "spy:7072"
SPY_SERVICE_FILTERS: | SPY_SERVICE_FILTERS: |
@ -32,8 +32,8 @@ services:
] ]
REST_PORT: "4200" REST_PORT: "4200"
PROM_PORT: "8081" PROM_PORT: "8081"
READINESS_SPY_SYNC_TIME_SECONDS: "20" READINESS_SPY_SYNC_TIME_SECONDS: "5"
READINESS_NUM_LOADED_SYMBOLS: "50" READINESS_NUM_LOADED_SYMBOLS: "280"
LOG_LEVEL: warning LOG_LEVEL: warning
WORMHOLE_CLUSTER: testnet WORMHOLE_CLUSTER: testnet
healthcheck: healthcheck:
@ -50,12 +50,20 @@ services:
depends_on: depends_on:
- spy - spy
price-pusher: price-pusher:
build: # Use this to build the price pusher from source. A dependency of the pusher docker
context: . # image is the pyth-crosschain monorepo lerna docker image. Build lerna image
# Uncomment this line (and comment out the above lines) to use a prebuilt image. Replace <version> # using the following command from the repo root:
# with the latest released image of the price pusher from this repo release page: # `docker buildx build -f tilt_devnet/docker_images/Dockerfile.lerna -t lerna .`
# https://github.com/pyth-network/pyth-crosschain/releases #
# image: public.ecr.aws/pyth-network/xc-price-pusher:v<version> # Please note that the docker build from source only works in x86_64 platforms
# and doesn't work on arm platforms (like Apple M1/M2).
#
# build:
# context: .
# Replace <version> with the latest released image of the price pusher from here:
# https://gallery.ecr.aws/pyth-network/xc-price-pusher
image: public.ecr.aws/pyth-network/xc-price-pusher:v<version>
restart: always restart: always
command: command:
- "--" - "--"

View File

@ -1,6 +1,6 @@
{ {
"name": "@pythnetwork/price-pusher", "name": "@pythnetwork/price-pusher",
"version": "5.4.3", "version": "5.4.4",
"description": "Pyth Price Pusher", "description": "Pyth Price Pusher",
"homepage": "https://pyth.network", "homepage": "https://pyth.network",
"main": "lib/index.js", "main": "lib/index.js",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pythnetwork/price-service-client", "name": "@pythnetwork/price-service-client",
"version": "1.6.0", "version": "1.6.1",
"description": "Pyth price service client", "description": "Pyth price service client",
"author": { "author": {
"name": "Pyth Data Association" "name": "Pyth Data Association"

View File

@ -62,7 +62,7 @@ export class PriceServiceConnection {
private wsClient: undefined | ResilientWebSocket; private wsClient: undefined | ResilientWebSocket;
private wsEndpoint: undefined | string; private wsEndpoint: undefined | string;
private logger: undefined | Logger; private logger: Logger;
private priceFeedRequestConfig: PriceFeedRequestConfig; private priceFeedRequestConfig: PriceFeedRequestConfig;
@ -96,9 +96,30 @@ export class PriceServiceConnection {
this.priceFeedCallbacks = new Map(); this.priceFeedCallbacks = new Map();
this.logger = config?.logger; // Default logger is console for only warnings and errors.
this.logger = config?.logger || {
trace: () => {},
debug: () => {},
info: () => {},
warn: console.warn,
error: console.error,
};
this.onWsError = (error: Error) => { this.onWsError = (error: Error) => {
this.logger?.error(error); this.logger.error(error);
// Exit the process if it is running in node.
if (
typeof process !== "undefined" &&
typeof process.exit === "function"
) {
this.logger.error("Halting the process due to the websocket error");
process.exit(1);
} else {
this.logger.error(
"Cannot halt process. Please handle the websocket error."
);
}
}; };
this.wsEndpoint = makeWebsocketUrl(endpoint); this.wsEndpoint = makeWebsocketUrl(endpoint);
@ -333,28 +354,28 @@ export class PriceServiceConnection {
binary: this.priceFeedRequestConfig.binary, binary: this.priceFeedRequestConfig.binary,
}; };
this.logger?.info("Resubscribing to existing price feeds."); this.logger.info("Resubscribing to existing price feeds.");
this.wsClient?.send(JSON.stringify(message)); this.wsClient?.send(JSON.stringify(message));
} }
}; };
this.wsClient.onMessage = (data: WebSocket.Data) => { this.wsClient.onMessage = (data: WebSocket.Data) => {
this.logger?.info(`Received message ${data.toString()}`); this.logger.info(`Received message ${data.toString()}`);
let message: ServerMessage; let message: ServerMessage;
try { try {
message = JSON.parse(data.toString()) as ServerMessage; message = JSON.parse(data.toString()) as ServerMessage;
} catch (e: any) { } catch (e: any) {
this.logger?.error(`Error parsing message ${data.toString()} as JSON.`); this.logger.error(`Error parsing message ${data.toString()} as JSON.`);
this.logger?.error(e); this.logger.error(e);
this.onWsError(e); this.onWsError(e);
return; return;
} }
if (message.type === "response") { if (message.type === "response") {
if (message.status === "error") { if (message.status === "error") {
this.logger?.error( this.logger.error(
`Error response from the websocket server ${message.error}.` `Error response from the websocket server ${message.error}.`
); );
this.onWsError(new Error(message.error)); this.onWsError(new Error(message.error));
@ -364,10 +385,10 @@ export class PriceServiceConnection {
try { try {
priceFeed = PriceFeed.fromJson(message.price_feed); priceFeed = PriceFeed.fromJson(message.price_feed);
} catch (e: any) { } catch (e: any) {
this.logger?.error( this.logger.error(
`Error parsing price feeds from message ${data.toString()}.` `Error parsing price feeds from message ${data.toString()}.`
); );
this.logger?.error(e); this.logger.error(e);
this.onWsError(e); this.onWsError(e);
return; return;
} }
@ -378,7 +399,7 @@ export class PriceServiceConnection {
} }
} }
} else { } else {
this.logger?.warn( this.logger.warn(
`Ignoring unsupported server response ${data.toString()}.` `Ignoring unsupported server response ${data.toString()}.`
); );
} }

View File

@ -1,7 +1,7 @@
services: services:
spy: spy:
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
image: ghcr.io/wormhole-foundation/guardiand:v2.17.0 image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
restart: on-failure restart: on-failure
command: command:
- "spy" - "spy"
@ -17,7 +17,7 @@ services:
- "warn" - "warn"
price-service: price-service:
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
image: public.ecr.aws/pyth-network/xc-server:v3.0.3 image: public.ecr.aws/pyth-network/xc-server:v3.0.8
restart: on-failure restart: on-failure
# Or alternatively use a locally built image # Or alternatively use a locally built image
# image: pyth_price_server # image: pyth_price_server
@ -36,8 +36,8 @@ services:
] ]
REST_PORT: "4200" REST_PORT: "4200"
PROM_PORT: "8081" PROM_PORT: "8081"
READINESS_SPY_SYNC_TIME_SECONDS: "20" READINESS_SPY_SYNC_TIME_SECONDS: "5"
READINESS_NUM_LOADED_SYMBOLS: "50" READINESS_NUM_LOADED_SYMBOLS: "280"
LOG_LEVEL: warning LOG_LEVEL: warning
WORMHOLE_CLUSTER: mainnet WORMHOLE_CLUSTER: mainnet
DB_API_CLUSTER: pythnet DB_API_CLUSTER: pythnet

View File

@ -1,7 +1,7 @@
services: services:
spy: spy:
# Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand # Find latest Guardian images in https://github.com/wormhole-foundation/wormhole/pkgs/container/guardiand
image: ghcr.io/wormhole-foundation/guardiand:v2.17.0 image: ghcr.io/wormhole-foundation/guardiand:v2.19.0
restart: on-failure restart: on-failure
command: command:
- "spy" - "spy"
@ -17,7 +17,7 @@ services:
- "warn" - "warn"
price-service: price-service:
# Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server # Find latest price service images https://gallery.ecr.aws/pyth-network/xc-server
image: public.ecr.aws/pyth-network/xc-server:v3.0.3 image: public.ecr.aws/pyth-network/xc-server:v3.0.8
restart: on-failure restart: on-failure
# Or alternatively use a locally built image # Or alternatively use a locally built image
# image: pyth_price_server # image: pyth_price_server
@ -36,8 +36,8 @@ services:
] ]
REST_PORT: "4200" REST_PORT: "4200"
PROM_PORT: "8081" PROM_PORT: "8081"
READINESS_SPY_SYNC_TIME_SECONDS: "20" READINESS_SPY_SYNC_TIME_SECONDS: "5"
READINESS_NUM_LOADED_SYMBOLS: "50" READINESS_NUM_LOADED_SYMBOLS: "280"
LOG_LEVEL: warning LOG_LEVEL: warning
WORMHOLE_CLUSTER: testnet WORMHOLE_CLUSTER: testnet
DB_API_CLUSTER: devnet DB_API_CLUSTER: devnet

View File

@ -1,6 +1,6 @@
{ {
"name": "@pythnetwork/pyth-terra-js", "name": "@pythnetwork/pyth-terra-js",
"version": "1.3.0", "version": "1.3.1",
"description": "Pyth Network Terra Utils in JS", "description": "Pyth Network Terra Utils in JS",
"homepage": "https://pyth.network", "homepage": "https://pyth.network",
"author": { "author": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pythnetwork/pyth-evm-js", "name": "@pythnetwork/pyth-evm-js",
"version": "1.20.0", "version": "1.20.1",
"description": "Pyth Network EVM Utils in JS", "description": "Pyth Network EVM Utils in JS",
"homepage": "https://pyth.network", "homepage": "https://pyth.network",
"author": { "author": {