Skip to content

Commit

Permalink
fix: [bots] remove wait for logger (#3711)
Browse files Browse the repository at this point in the history
* fix: [bots] remove wait for logger

Signed-off-by: chrismaree <[email protected]>

* fix

Signed-off-by: chrismaree <[email protected]>

* fix

Signed-off-by: chrismaree <[email protected]>
  • Loading branch information
chrismaree authored Dec 17, 2021
1 parent 95ef1c5 commit a06c0f3
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/bot-strategy-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function runStrategies(strategyRunnerConfig: strategyRunnerConfig) {
message: "End of execution loop - terminating process",
});

await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
if (strategyRunnerConfig.emitRunnerLogs)
Expand Down
7 changes: 3 additions & 4 deletions packages/contract-notifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require("dotenv").config();
const retry = require("async-retry");

// Helpers:
const { Networker, Logger, waitForLogger, delay } = require("@uma/financial-templates-lib");
const { Networker, Logger, delay } = require("@uma/financial-templates-lib");

const { ContractNotifier } = require("./src/ContractNotifier");

Expand Down Expand Up @@ -65,8 +65,7 @@ async function run({ logger, pollingDelay, errorRetries, errorRetriesTimeout, no
at: "ContractNotifier#index",
message: "End of serverless execution loop - terminating process",
});
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down Expand Up @@ -115,7 +114,7 @@ async function Poll(callback) {
error: typeof error === "string" ? new Error(error) : error,
notificationPath: "infrastructure-error",
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
6 changes: 2 additions & 4 deletions packages/disputer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const {
Logger,
Networker,
delay,
waitForLogger,
createReferencePriceFeedForFinancialContract,
setAllowance,
DSProxyManager,
Expand Down Expand Up @@ -245,8 +244,7 @@ async function run({
// If the polling delay is set to 0 then the script will terminate the bot after one full run.
if (pollingDelay === 0) {
logger.debug({ at: "Disputer#index", message: "End of serverless execution loop - terminating process" });
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down Expand Up @@ -318,7 +316,7 @@ async function Poll(callback) {
error: typeof error === "string" ? new Error(error) : error,
notificationPath: "infrastructure-error",
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
7 changes: 3 additions & 4 deletions packages/funding-rate-proposer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const retry = require("async-retry");

const {
Logger,
waitForLogger,
delay,
FinancialContractFactoryClient,
GasEstimator,
Expand Down Expand Up @@ -116,8 +115,8 @@ async function run({
at: "PerpetualFundingRateProposer#index",
message: "End of serverless execution loop - terminating process",
});
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.

await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down Expand Up @@ -171,7 +170,7 @@ async function Poll(callback) {
message: "Perpetual funding rate proposer execution error🚨",
error: typeof error === "string" ? new Error(error) : error,
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
5 changes: 2 additions & 3 deletions packages/fx-tunnel-relayer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { config } from "dotenv";
import MaticJs from "@maticnetwork/maticjs";
import { averageBlockTimeSeconds, getWeb3 } from "@uma/common";
import { getAddress, getAbi } from "@uma/contracts-node";
import { GasEstimator, Logger, waitForLogger, delay } from "@uma/financial-templates-lib";
import { GasEstimator, Logger, delay } from "@uma/financial-templates-lib";

import { Relayer } from "./Relayer";
import { RelayerConfig } from "./RelayerConfig";
Expand Down Expand Up @@ -102,8 +102,7 @@ export async function run(logger: winston.Logger, web3: Web3): Promise<void> {
at: "FxTunnelRelayer#index",
message: "End of serverless execution loop - terminating process",
});
await waitForLogger(logger);
await delay(2);
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down
4 changes: 1 addition & 3 deletions packages/insured-bridge-relayer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getWeb3, getWeb3ByChainId, processTransactionPromiseBatch, getRetryWeb3
import {
GasEstimator,
Logger,
waitForLogger,
delay,
InsuredBridgeL1Client,
InsuredBridgeL2Client,
Expand Down Expand Up @@ -166,8 +165,7 @@ export async function run(logger: winston.Logger, l1Web3: Web3): Promise<void> {
at: "AcrossRelayer#index",
message: "End of serverless execution loop - terminating process",
});
await delay(5);
await waitForLogger(logger);
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down
6 changes: 2 additions & 4 deletions packages/liquidator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {
Networker,
Logger,
createReferencePriceFeedForFinancialContract,
waitForLogger,
delay,
setAllowance,
DSProxyManager,
Expand Down Expand Up @@ -329,8 +328,7 @@ async function run({
// If the polling delay is set to 0 then the script will terminate the bot after one full run.
if (pollingDelay === 0) {
logger.debug({ at: "Liquidator#index", message: "End of serverless execution loop - terminating process" });
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down Expand Up @@ -416,7 +414,7 @@ async function Poll(callback) {
error: typeof error === "string" ? new Error(error) : error,
notificationPath: "infrastructure-error",
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
6 changes: 2 additions & 4 deletions packages/monitors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const {
Logger,
createReferencePriceFeedForFinancialContract,
createTokenPriceFeedForFinancialContract,
waitForLogger,
delay,
multicallAddressMap,
OptimisticOracleType,
Expand Down Expand Up @@ -384,8 +383,7 @@ async function run({
// If the polling delay is set to 0 then the script will terminate the bot after one full run.
if (pollingDelay === 0) {
logger.debug({ at: "Monitor#index", message: "End of serverless execution loop - terminating process" });
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({ at: "Monitor#index", message: "End of execution loop - waiting polling delay" });
Expand Down Expand Up @@ -485,7 +483,7 @@ async function Poll(callback) {
error: typeof error === "string" ? new Error(error) : error,
notificationPath: "infrastructure-error",
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
6 changes: 2 additions & 4 deletions packages/optimistic-oracle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const retry = require("async-retry");

const {
Logger,
waitForLogger,
delay,
OptimisticOracleClient,
GasEstimator,
Expand Down Expand Up @@ -127,8 +126,7 @@ async function run({
at: "OptimisticOracle#index",
message: "End of serverless execution loop - terminating process",
});
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down Expand Up @@ -186,7 +184,7 @@ async function Poll(callback) {
error: typeof error === "string" ? new Error(error) : error,
notificationPath: "infrastructure-error",
});
await waitForLogger(Logger);
await delay(5); // Set a delay to let the transports flush fully.
callback(error);
}
callback();
Expand Down
4 changes: 1 addition & 3 deletions packages/serverless-orchestration/src/ServerlessHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const datastore = new Datastore();
// Web3 instance to get current block numbers of polling loops.
const Web3 = require("web3");

const { delay, createNewLogger, waitForLogger } = require("@uma/financial-templates-lib");
const { delay, createNewLogger } = require("@uma/financial-templates-lib");
let customLogger;
let spokeUrl;
let customNodeUrl;
Expand Down Expand Up @@ -211,7 +211,6 @@ hub.post("/", async (req, res) => {
output: { errorOutputs, validOutputs, retriedOutputs },
});

await waitForLogger(logger);
await delay(waitForLoggerDelay); // Wait a few seconds to be sure the the winston logs are processed upstream.
res
.status(200)
Expand Down Expand Up @@ -256,7 +255,6 @@ hub.post("/", async (req, res) => {
});
}

await waitForLogger(logger);
await delay(waitForLoggerDelay); // Wait a few seconds to be sure the the winston logs are processed upstream.
res.status(500).send({
message: errorOutput instanceof Error ? "A fatal error occurred in the hub" : "Some spoke calls returned errors",
Expand Down
4 changes: 1 addition & 3 deletions packages/trader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
Logger,
createReferencePriceFeedForFinancialContract,
createTokenPriceFeedForFinancialContract,
waitForLogger,
delay,
DSProxyManager,
} from "@uma/financial-templates-lib";
Expand Down Expand Up @@ -121,8 +120,7 @@ export async function run(logger: winston.Logger, web3: Web3): Promise<void> {
at: "Trader#index",
message: "End of serverless execution loop - terminating process",
});
await waitForLogger(logger);
await delay(2); // waitForLogger does not always work 100% correctly in serverless. add a delay to ensure logs are captured upstream.
await delay(5); // Set a delay to let the transports flush fully.
break;
}
logger.debug({
Expand Down

0 comments on commit a06c0f3

Please sign in to comment.