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

node-opcua / node-opcua / 23974043205

04 Apr 2026 07:17AM UTC coverage: 92.589% (+0.01%) from 92.576%
23974043205

push

github

erossignon
chore: fix Mocha.Suite.settimeout misused

18408 of 21832 branches covered (84.32%)

161708 of 174651 relevant lines covered (92.59%)

461089.77 hits per line

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

95.18
/packages/node-opcua-server/source/i_server_side_publish_engine.ts
1
import assert from "node-opcua-assert";
2✔
2
import type { ExtensionObject } from "node-opcua-extension-object";
2✔
3
import type { SequenceNumberGenerator } from "node-opcua-secure-channel";
2✔
4
import { PublishResponse, type PublishResponseOptions, type StatusChangeNotification } from "node-opcua-types";
2✔
5
import type { Subscription } from "./server_subscription";
2✔
6

2✔
7
export interface INotifMsg {
2✔
8
    subscriptionId: number;
2✔
9
    sequenceNumber: number;
2✔
10
    notificationData: (ExtensionObject | null)[] | null;
2✔
11
    moreNotifications: boolean;
2✔
12
}
2✔
13

2✔
14
export interface IServerSidePublishEngine {
2✔
15
    on_close_subscription(subscription: IClosedOrTransferredSubscription): void;
2✔
16
    readonly pendingPublishRequestCount: number;
2✔
17
    _on_tick(): void;
2✔
18
    send_keep_alive_response(subscriptionId: number, future_sequence_number: number): boolean;
2✔
19
    _send_response(subscription: Subscription, options: PublishResponseOptions): void;
2✔
20
}
2✔
21

2✔
22
export interface IClosedOrTransferredSubscription {
2✔
23
    readonly hasPendingNotifications: boolean;
2✔
24
    dispose(): void;
2✔
25
    readonly id: number;
2✔
26
    _publish_pending_notifications(): void;
2✔
27
}
2✔
28
export class TransferredSubscription implements IClosedOrTransferredSubscription {
4✔
29
    public id: number;
15✔
30
    public publishEngine: IServerSidePublishEngine | null;
15✔
31
    public _pending_notification?: StatusChangeNotification;
15✔
32
    private _sequence_number_generator: SequenceNumberGenerator | null;
15✔
33
    constructor(options: { id: number; generator: SequenceNumberGenerator; publishEngine: IServerSidePublishEngine }) {
15✔
34
        this.id = options.id;
15✔
35
        this._sequence_number_generator = options.generator;
15✔
36
        this.publishEngine = options.publishEngine;
15✔
37
    }
15✔
38
    public get hasPendingNotifications(): boolean {
15✔
39
        return !!this._pending_notification;
21✔
40
    }
21✔
41
    dispose(): void {
15✔
42
        this._pending_notification = undefined;
14✔
43
        this.publishEngine = null;
14✔
44
    }
14✔
45
    _publish_pending_notifications(): void {
15✔
46
        if (!this._pending_notification) {
8✔
47
            throw new Error("Internal Error: no pending notification");
×
48
        }
×
49
        const notificationMessage = this._pending_notification;
8✔
50
        this._pending_notification = undefined;
8✔
51
        const moreNotifications = false;
8✔
52
        const subscriptionId = this.id;
8✔
53

8✔
54
        const response = new PublishResponse({
8✔
55
            moreNotifications,
8✔
56
            notificationMessage: {
8✔
57
                notificationData: [notificationMessage],
8✔
58
                publishTime: new Date(),
8✔
59
                sequenceNumber: 0xffffffff
8✔
60
            },
8✔
61
            subscriptionId
8✔
62
        });
8✔
63

8✔
64
        // apply sequence number and store in sent_notifications queue
8✔
65
        assert(response.notificationMessage.sequenceNumber === 0xffffffff);
8✔
66
        response.notificationMessage.sequenceNumber = this._get_next_sequence_number();
8✔
67
        // xxx    this._sent_notifications.push(response.notificationMessage);
8✔
68
        // get available sequence number;
8✔
69
        const availableSequenceNumbers = [response.notificationMessage.sequenceNumber];
8✔
70
        assert(
8✔
71
            !response.notificationMessage ||
8✔
72
                availableSequenceNumbers[availableSequenceNumbers.length - 1] === response.notificationMessage.sequenceNumber
8✔
73
        );
8✔
74
        response.availableSequenceNumbers = availableSequenceNumbers;
8✔
75
        if (!this.publishEngine) {
8✔
76
            throw new Error("Internal Error: publishEngine is null");
×
77
        }
×
78
        this.publishEngine._send_response(this as unknown as Subscription, response);
8✔
79
    }
8✔
80
    private _get_next_sequence_number(): number {
15✔
81
        return this._sequence_number_generator ? this._sequence_number_generator.next() : 0;
8✔
82
    }
8✔
83
}
15✔
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