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

safe-global / safe-client-gateway / 12595573134

03 Jan 2025 09:26AM UTC coverage: 89.902% (-0.2%) from 90.126%
12595573134

Pull #2232

github

web-flow
Merge c1013c948 into 48e5bc4de
Pull Request #2232: Add Timeout to Redis Queries and Handle Client Unavailability Gracefully

2856 of 3561 branches covered (80.2%)

Branch coverage included in aggregate %.

39 of 70 new or added lines in 6 files covered. (55.71%)

12 existing lines in 2 files now uncovered.

9679 of 10382 relevant lines covered (93.23%)

436.83 hits per line

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

66.67
/src/domain/common/utils/promise.ts
1
import { HttpException, HttpStatus } from '@nestjs/common';
122✔
2

3
export const promiseWithTimeout = <T>(
122✔
4
  promise: Promise<T>,
5
  timeout: number,
6
): Promise<T | undefined> => {
7
  let timeoutId: NodeJS.Timeout;
8

9
  return Promise.race<T | undefined>([
1,324✔
10
    promise,
11
    new Promise((_, reject) => {
12
      timeoutId = setTimeout(
1,324✔
NEW
13
        () => reject(new PromiseTimeoutError('Promise timed out!', 500)),
×
14
        timeout,
15
      );
16
    }),
17
  ]).finally(() => {
18
    clearTimeout(timeoutId);
1,324✔
19
  });
20
};
21

22
export class PromiseTimeoutError extends HttpException {
122✔
23
  //
24
  public constructor(
25
    message: string,
26
    statusCode: number = HttpStatus.SERVICE_UNAVAILABLE,
×
27
  ) {
NEW
28
    super(message, statusCode);
×
29
  }
30
}
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

© 2025 Coveralls, Inc