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

rokucommunity / roku-debug / #2013

pending completion
#2013

push

web-flow
Merge 5cc22ee11 into f30a7deaa

1850 of 2724 branches covered (67.91%)

Branch coverage included in aggregate %.

1866 of 1866 new or added lines in 41 files covered. (100.0%)

3398 of 4571 relevant lines covered (74.34%)

25.87 hits per line

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

78.26
/src/managers/ActionQueue.ts
1
import type { Deferred } from '../util';
2
import { defer } from '../util';
1✔
3

4
/**
5
 * A runner that will keep retrying an action until it succeeds, while also queueing up future actions.
6
 * Will run until all pending actions are complete.
7
 */
8
export class ActionQueue {
1✔
9

10
    private queueItems: Array<{
195✔
11
        action: () => boolean | Promise<boolean>;
12
        deferred: Deferred<any>;
13
    }> = [];
14

15
    /**
16
     * Run an action in the queue.
17
     * @param action return true or Promise<true> to mark the action as finished
18
     */
19
    public async run(action: () => boolean | Promise<boolean>) {
20
        this.queueItems.push({
330✔
21
            action: action,
22
            deferred: defer()
23
        });
24
        await this._runActions();
330✔
25
    }
26

27
    private isRunning = false;
195✔
28

29
    private async _runActions() {
30
        if (this.isRunning) {
330!
31
            return;
×
32
        }
33
        this.isRunning = true;
330✔
34
        while (this.queueItems.length > 0) {
330✔
35
            const queueItem = this.queueItems[0];
330✔
36
            try {
330✔
37
                const isFinished = await Promise.resolve(
330✔
38
                    queueItem.action()
39
                );
40
                if (isFinished) {
330!
41
                    this.queueItems.shift();
330✔
42
                    queueItem.deferred.resolve();
330✔
43
                }
44
            } catch (error) {
45
                this.queueItems.shift();
×
46
                queueItem.deferred.reject(error);
×
47
            }
48
        }
49
        this.isRunning = false;
330✔
50
    }
51
}
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