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

mongodb-js / mongodb-mcp-server / 16415132941

21 Jul 2025 10:58AM UTC coverage: 80.343% (-1.5%) from 81.82%
16415132941

Pull #361

github

web-flow
Merge 1297ed957 into 7856bb93a
Pull Request #361: feat: add streamable http [MCP-42]

545 of 715 branches covered (76.22%)

Branch coverage included in aggregate %.

248 of 409 new or added lines in 10 files covered. (60.64%)

9 existing lines in 1 file now uncovered.

3109 of 3833 relevant lines covered (81.11%)

47.21 hits per line

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

93.18
/src/common/timeoutManager.ts
1
/**
2
 * A class that manages timeouts for a callback function.
3
 * It is used to ensure that a callback function is called after a certain amount of time.
4
 * If the callback function is not called after the timeout, it will be called with an error.
5
 */
6
export class TimeoutManager {
2✔
7
    private timeoutId?: NodeJS.Timeout;
8

9
    /**
10
     * A callback function that is called when the timeout is reached.
11
     */
12
    public onerror?: (error: unknown) => void;
13

14
    /**
15
     * Creates a new TimeoutManager.
16
     * @param callback - A callback function that is called when the timeout is reached.
17
     * @param timeoutMS - The timeout in milliseconds.
18
     */
19
    constructor(
2✔
20
        private readonly callback: () => Promise<void> | void,
16✔
21
        private readonly timeoutMS: number
16✔
22
    ) {
16✔
23
        if (timeoutMS <= 0) {
16!
NEW
24
            throw new Error("timeoutMS must be greater than 0");
×
NEW
25
        }
×
26
        this.reset();
16✔
27
    }
16✔
28

29
    /**
30
     * Clears the timeout.
31
     */
32
    clear() {
2✔
33
        if (this.timeoutId) {
40✔
34
            clearTimeout(this.timeoutId);
24✔
35
            this.timeoutId = undefined;
24✔
36
        }
24✔
37
    }
40✔
38

39
    /**
40
     * Runs the callback function.
41
     */
42
    private async runCallback() {
2✔
43
        if (this.callback) {
10✔
44
            try {
10✔
45
                await this.callback();
10✔
46
            } catch (error: unknown) {
10✔
47
                this.onerror?.(error);
2✔
48
            }
2✔
49
        }
10✔
50
    }
10✔
51

52
    /**
53
     * Resets the timeout.
54
     */
55
    reset() {
2✔
56
        this.clear();
34✔
57
        this.timeoutId = setTimeout(() => {
34✔
58
            void this.runCallback().finally(() => {
10✔
59
                this.timeoutId = undefined;
10✔
60
            });
10✔
61
        }, this.timeoutMS);
34✔
62
    }
34✔
63
}
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