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

haraka / Haraka / 25929385750

15 May 2026 04:35PM UTC coverage: 72.494% (-0.03%) from 72.525%
25929385750

push

github

web-flow
Release v3.1.6 (#3555)

- fix(outbound): release queue slot when qfile unreadable #3561
- fix(message-stream): add `unpipe` for pipe cleanup after errors
- fix(outbound): guard against error emit after listeners removed #3554
- fix(outbound): yield before delivery attempts #3552
- test(outbound,conn,endpoint,server,tls_socket): added tests #3552
- deps(various): updated to latest
- dep(ocsp): replaced fork with local (more maintained) fork #3550
- dep(npid, sockaddr): removed #3550
- dep(daemon): removed, unmaintained #3550
- doc(SECURITY): added threat model #3557
- doc(SECURITY): added #3550
- doc(Connection): added 15 undocumented methods
- doc: add a fresh coat of paint to README and docs/*
  - add missing properties and functions
  - sync with codebase, fix inaccuracies, and add examples
  - improve formatting and readability
- package.json: remove optional lesser used plugins #3550
  - avg, elasticsearch, esets, p0f, recip-routes, watch

1528 of 2027 branches covered (75.38%)

6979 of 9627 relevant lines covered (72.49%)

23.13 hits per line

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

91.86
/outbound/timer_queue.js
1
'use strict'
8✔
2

8✔
3
const logger = require('../logger')
8✔
4

8✔
5
class TQTimer {
8✔
6
    constructor(id, fire_time, cb) {
8✔
7
        this.id = id
11✔
8
        this.fire_time = fire_time
11✔
9
        this.cb = cb
11✔
10
    }
11✔
11

8✔
12
    cancel() {
8✔
13
        this.cb = null
2✔
14
    }
2✔
15
}
8✔
16

8✔
17
class TimerQueue {
8✔
18
    constructor(interval = 1000) {
8✔
19
        this.name = 'outbound/timer_queue'
14✔
20
        this.queue = []
14✔
21
        this.interval_timer = setInterval(() => {
14✔
22
            this.fire()
16✔
23
        }, interval)
14✔
24
        this.interval_timer.unref() // allow server to exit
14✔
25
    }
14✔
26

8✔
27
    add(id, ms, cb) {
8✔
28
        const fire_time = Date.now() + ms
11✔
29

11✔
30
        const timer = new TQTimer(id, fire_time, cb)
11✔
31

11✔
32
        if (this.queue.length === 0 || fire_time >= this.queue[this.queue.length - 1].fire_time) {
11✔
33
            this.queue.push(timer)
10✔
34
            return timer
10✔
35
        }
10✔
36

1✔
37
        for (let i = 0; i < this.queue.length; i++) {
1✔
38
            if (this.queue[i].fire_time > fire_time) {
1✔
39
                this.queue.splice(i, 0, timer)
1✔
40
                return timer
1✔
41
            }
1✔
42
        }
1✔
43

×
44
        throw 'Should never get here'
×
45
    }
11✔
46

8✔
47
    discard(id) {
8✔
48
        for (let i = 0; i < this.queue.length; i++) {
2✔
49
            if (this.queue[i].id === id) {
3✔
50
                this.queue[i].cancel()
2✔
51
                return this.queue.splice(i, 1)
2✔
52
            }
2✔
53
        }
3✔
54

×
55
        throw `${id} not found`
×
56
    }
2✔
57

8✔
58
    fire() {
8✔
59
        if (this.queue.length === 0) return
16✔
60

9✔
61
        const now = Date.now()
9✔
62

9✔
63
        while (this.queue.length && this.queue[0].fire_time <= now) {
16!
64
            const to_run = this.queue.shift()
×
65
            if (to_run.cb) to_run.cb()
×
66
        }
×
67
    }
16✔
68

8✔
69
    length() {
8✔
70
        return this.queue.length
11✔
71
    }
11✔
72

8✔
73
    drain() {
8✔
74
        logger.debug(this, `Draining ${this.queue.length} items from the queue`)
1✔
75
        while (this.queue.length) {
1✔
76
            const to_run = this.queue.shift()
2✔
77
            if (to_run.cb) to_run.cb()
2!
78
        }
2✔
79
    }
1✔
80

8✔
81
    shutdown() {
8✔
82
        clearInterval(this.interval_timer)
4✔
83
    }
4✔
84
}
8✔
85

8✔
86
module.exports = TimerQueue
8✔
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