Skip to content

fix: remove unneeded listeners that cleared caches #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ export const initServer = async () => {

writeOpenApiToFile(server);
await updateTxListener();
await clearCacheCron("server");
await clearCacheCron();
};
2 changes: 1 addition & 1 deletion src/server/routes/configuration/cache/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function updateCacheConfiguration(fastify: FastifyInstance) {
await updateConfiguration({ ...req.body });
const config = await getConfig(false);
// restarting cache cron with updated cron schedule
await clearCacheCron("server");
await clearCacheCron();
res.status(StatusCodes.OK).send({
result: {
clearCacheCronSchedule: config.clearCacheCronSchedule,
Expand Down
5 changes: 1 addition & 4 deletions src/shared/utils/cache/clear-cache.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import type { env } from "../env";
import { accessTokenCache } from "./access-token";
import { invalidateConfig } from "./get-config";
import { sdkCache } from "./get-sdk";
import { walletsCache } from "./get-wallet";
import { webhookCache } from "./get-webhook";
import { keypairCache } from "./keypair";

export const clearCache = async (
_service: (typeof env)["LOG_SERVICES"][0],
): Promise<void> => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused var

export const clearCache = async (): Promise<void> => {
invalidateConfig();
webhookCache.clear();
sdkCache.clear();
Expand Down
7 changes: 2 additions & 5 deletions src/shared/utils/cron/clear-cache-cron.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { CronJob } from "cron";
import { clearCache } from "../cache/clear-cache";
import { getConfig } from "../cache/get-config";
import type { env } from "../env";

let task: CronJob;

export const clearCacheCron = async (
service: (typeof env)["LOG_SERVICES"][0],
) => {
export const clearCacheCron = async () => {
const config = await getConfig();

if (!config.clearCacheCronSchedule) {
Expand All @@ -20,7 +17,7 @@ export const clearCacheCron = async (
}

task = new CronJob(config.clearCacheCronSchedule, async () => {
await clearCache(service);
await clearCache();
});
task.start();
};
12 changes: 0 additions & 12 deletions src/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import {
newConfigurationListener,
updatedConfigurationListener,
} from "./listeners/config-listener";

Check failure on line 5 in src/worker/index.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module './listeners/config-listener' or its corresponding type declarations.
import {
newWebhooksListener,
updatedWebhooksListener,
} from "./listeners/webhook-listener";
import { initCancelRecycledNoncesWorker } from "./tasks/cancel-recycled-nonces-worker";
import { initMineTransactionWorker } from "./tasks/mine-transaction-worker";
import { initNonceHealthCheckWorker } from "./tasks/nonce-health-check-worker";
Expand All @@ -31,14 +27,6 @@
await initNonceResyncWorker();
await initWalletSubscriptionWorker();

// Listen for new & updated configuration data.
await newConfigurationListener();
await updatedConfigurationListener();

// Listen for new & updated webhooks data.
await newWebhooksListener();
await updatedWebhooksListener();

// Contract subscriptions.
await chainIndexerListener();
};
114 changes: 0 additions & 114 deletions src/worker/listeners/config-listener.ts

This file was deleted.

115 changes: 0 additions & 115 deletions src/worker/listeners/webhook-listener.ts

This file was deleted.

Loading