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

u-wave / core / 23186055882

17 Mar 2026 08:53AM UTC coverage: 87.253% (+0.02%) from 87.235%
23186055882

Pull #755

github

web-flow
Merge f26a7074c into d68af310c
Pull Request #755: Remove Redis

1055 of 1249 branches covered (84.47%)

Branch coverage included in aggregate %.

100 of 111 new or added lines in 8 files covered. (90.09%)

18 existing lines in 2 files now uncovered.

10801 of 12339 relevant lines covered (87.54%)

108.27 hits per line

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

90.2
/src/sockets/LostConnection.js
1
import Emittery from 'emittery';
1✔
2

1✔
3
/**
1✔
4
 * @augments {Emittery<{ close: undefined }>}
1✔
5
 */
1✔
6
class LostConnection extends Emittery {
1✔
7
  #logger;
2✔
8

2✔
9
  #expiresAt;
2✔
10

2✔
11
  /** @type {import('express-session').Store} */
2✔
12
  #sessionStore;
2✔
13

2✔
14
  /**
2✔
15
   * @param {import('../Uwave.js').default} uw
2✔
16
   * @param {import('express-session').Store} store
2✔
17
   * @param {import('../schema.js').User} user
2✔
18
   * @param {string} sessionID
2✔
19
   * @param {string|null} lastEventID
2✔
20
   */
2✔
21
  constructor(uw, store, user, sessionID, lastEventID, timeout = 30) {
2✔
22
    super();
2✔
23
    this.#sessionStore = store;
2✔
24
    this.user = user;
2✔
25
    this.sessionID = sessionID;
2✔
26
    this.#expiresAt = Date.now() + timeout * 1_000;
2✔
27
    this.#logger = uw.logger.child({
2✔
28
      ns: 'uwave:sockets',
2✔
29
      connectionType: 'LostConnection',
2✔
30
      userID: this.user.id,
2✔
31
      sessionID,
2✔
32
    });
2✔
33

2✔
34
    if (lastEventID != null) {
2✔
35
      this.#initQueued(lastEventID);
2✔
36
    }
2✔
37
  }
2✔
38

2✔
39
  /**
2✔
40
   * @param {string} lastEventID
2✔
41
   */
2✔
42
  #initQueued(lastEventID) {
2✔
43
    return new Promise((resolve, reject) => {
2✔
44
      this.#sessionStore.load(this.sessionID, (err, sessionData) => {
2✔
45
        if (err != null) {
2!
NEW
46
          reject(err);
×
47
        } else {
2✔
48
          // TODO: can i populate `sessionData.cookie` here?
2✔
49
          this.#sessionStore.set(this.sessionID, { ...sessionData, lastEventID }, (err) => {
2✔
50
            if (err != null) {
2!
NEW
51
              reject(err);
×
52
            } else {
2✔
53
              resolve(undefined);
2✔
54
            }
2✔
55
          });
2✔
56
        }
2✔
57
      });
2✔
58
    });
2✔
59
  }
2✔
60

2✔
61
  /**
2✔
62
   * @param {string} id
2✔
63
   * @param {string} command
2✔
64
   * @param {import('type-fest').JsonValue} data
2✔
65
   */
2✔
66
  send(id, command, data) {
2✔
67
    this.#logger.info({ id, command, data }, 'queue command');
2✔
68
  }
2✔
69

2✔
70
  ping() {
2✔
71
    if (Date.now() > this.#expiresAt) {
×
72
      this.close();
×
73
    }
×
74
  }
×
75

2✔
76
  close() {
2✔
77
    this.#logger.info('close');
1✔
78
    this.emit('close');
1✔
79
  }
1✔
80

2✔
81
  removed() {
2✔
82
    // Nothing to do
2✔
83
  }
2✔
84

2✔
85
  toString() {
2✔
86
    return `Lost { user: ${this.user.id} ${this.user.username} }`;
×
87
  }
×
88
}
2✔
89

1✔
90
export default LostConnection;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc