• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yiming-liao / logry / 16290302677

15 Jul 2025 10:04AM UTC coverage: 96.831% (+0.7%) from 96.15%
16290302677

push

github

yiming-liao
fix(core/handler-manager): prevent duplicate handler IDs and expose internal maps

Avoids memory leaks by ensuring handler IDs are unique.
Exported loggerMap and coreMap to support internal testing.

443 of 492 branches covered (90.04%)

Branch coverage included in aggregate %.

13 of 15 new or added lines in 3 files covered. (86.67%)

22 existing lines in 5 files now uncovered.

3987 of 4083 relevant lines covered (97.65%)

4.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.37
/src/core/handler-manager/utils/execute-handler.ts
1
import type { OnErrorCallback } from "@/core/handler-manager/handler-manager-config-types";
1✔
2
import type { Handler } from "@/core/handler-manager/types";
1✔
3
import type { RawPayload } from "@/shared/types/log-payload";
1✔
4
import { isHandlerClass } from "@/core/handler-manager/utils/is-handler-class";
1✔
5

1✔
6
type ExecuteHandlerOptions = {
1✔
7
  handler: Handler;
1✔
8
  id: string;
1✔
9
  rawPayload: RawPayload;
1✔
10
  onError?: OnErrorCallback;
1✔
11
};
1✔
12

1✔
13
/**
1✔
14
 * Executes a logging handler with the provided payload.
1✔
15
 * Supports handlers defined as functions or as class instances with a `handle` method.
1✔
16
 * If the handler throws an error, it will be caught and passed to the optional error callback.
1✔
17
 *
1✔
18
 * @param handler - The handler to execute (function or class instance).
1✔
19
 * @param id - Identifier for the handler, used in error callback.
1✔
20
 * @param rawPayload - The raw log payload to be passed to the handler.
1✔
21
 * @param onError - Optional callback to handle errors thrown by the handler.
1✔
22
 */
1✔
23
export const executeHandler = async ({
1✔
24
  handler,
2✔
25
  id,
2✔
26
  rawPayload,
2✔
27
  onError,
2✔
28
}: ExecuteHandlerOptions): Promise<void> => {
2✔
29
  try {
2✔
30
    if (typeof handler === "function") {
2✔
31
      await handler(rawPayload);
2✔
32
    } else if (isHandlerClass(handler)) {
2!
UNCOV
33
      await handler.handle(rawPayload);
×
UNCOV
34
    }
×
35
  } catch (error) {
2!
UNCOV
36
    onError?.({ error, id });
×
UNCOV
37
  }
×
38
};
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc