From 40fa6491fb46fd7a61caae0b2915e66ca6815665 Mon Sep 17 00:00:00 2001 From: KoshaevEugeny <103786108+akulistus@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:34:49 +0300 Subject: [PATCH 1/2] feat(workers): catch-unhandled-exceptions (#532) * feat(workers): add decorator to catch unhandled exceptions and report them to Hawk with worker type context * fix lint * Revert "fix lint" This reverts commit 7a7c0a94b3cc95b1e97af1b33b9d899935631cf3. * Revert "feat(workers): add decorator to catch unhandled exceptions and report them to Hawk with worker type context" This reverts commit ebb1fd74a0ee627ba903fc763760ca0361739283. * refactor(runner): add active worker names to HawkCatcher context --- runner.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/runner.ts b/runner.ts index 443beea8..5dd05b1b 100644 --- a/runner.ts +++ b/runner.ts @@ -12,10 +12,6 @@ import * as dotenv from 'dotenv'; dotenv.config(); -if (process.env.HAWK_CATCHER_TOKEN) { - HawkCatcher.init(process.env.HAWK_CATCHER_TOKEN); -} - type WorkerConstructor = new () => Worker; const BEGINNING_OF_ARGS = 2; @@ -27,6 +23,18 @@ const BEGINNING_OF_ARGS = 2; */ const workerNames = process.argv.slice(BEGINNING_OF_ARGS); +/** + * Initialize HawkCatcher +*/ +if (process.env.HAWK_CATCHER_TOKEN) { + HawkCatcher.init({ + token: process.env.HAWK_CATCHER_TOKEN, + context: { + workerTypes: workerNames.join(","), + } + }); +} + /** * Workers dispatcher. * Load, run and finish workers. From d1c7af4d724dbe3ae62906282c877f88b4ec0cf2 Mon Sep 17 00:00:00 2001 From: e11sy <130844513+e11sy@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:27:33 +0300 Subject: [PATCH 2/2] fix(): redis never throws key does not exist (#539) --- workers/grouper/src/redisHelper.ts | 32 ++++++++++-------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/workers/grouper/src/redisHelper.ts b/workers/grouper/src/redisHelper.ts index ec486ddb..57a35543 100644 --- a/workers/grouper/src/redisHelper.ts +++ b/workers/grouper/src/redisHelper.ts @@ -193,17 +193,11 @@ export default class RedisHelper { ): Promise { const timestamp = Date.now(); - try { - await this.tsIncrBy(key, value, timestamp, labels); - } catch (error) { - if (error instanceof Error && error.message.includes('TSDB: key does not exist')) { - this.logger.warn(`TS key ${key} does not exist, creating it...`); - await this.tsCreateIfNotExists(key, labels, retentionMs); - await this.tsIncrBy(key, value, timestamp, labels); - } else { - throw error; - } - } + /** + * Create key if not exists — then call increment + */ + await this.tsCreateIfNotExists(key, labels, retentionMs); + await this.tsIncrBy(key, value, timestamp, labels); } /** @@ -252,17 +246,11 @@ export default class RedisHelper { ): Promise { const timestamp = Date.now(); - try { - await this.tsAdd(key, value, timestamp, labels); - } catch (error) { - if (error instanceof Error && error.message.includes('TSDB: key does not exist')) { - this.logger.warn(`TS key ${key} does not exist, creating it...`); - await this.tsCreateIfNotExists(key, labels, retentionMs); - await this.tsAdd(key, value, timestamp, labels); - } else { - throw error; - } - } + /** + * Create key if not exists — then call increment + */ + await this.tsCreateIfNotExists(key, labels, retentionMs); + await this.tsAdd(key, value, timestamp, labels); } /**