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

cameri / nostream / 25207542759

01 May 2026 08:07AM UTC coverage: 62.181% (-2.4%) from 64.58%
25207542759

Pull #591

github

web-flow
Merge 29f984796 into d8f62b496
Pull Request #591: fix: add husky install fallback

1679 of 3060 branches covered (54.87%)

Branch coverage included in aggregate %.

3944 of 5983 relevant lines covered (65.92%)

7.88 hits per line

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

39.47
/src/app/worker.ts
1
import { IRunnable } from '../@types/base'
2
import { IWebSocketServerAdapter } from '../@types/adapters'
3

4
import { closeCacheClient } from '../cache/client'
1✔
5
import { createLogger } from '../factories/logger-factory'
1✔
6
import { FSWatcher } from 'fs'
7
import { SettingsStatic } from '../utils/settings'
1✔
8

9
const logger = createLogger('app-worker')
1✔
10
export class AppWorker implements IRunnable {
1✔
11
  private watchers: FSWatcher[] | undefined
12

13
  public constructor(
14
    private readonly process: NodeJS.Process,
1✔
15
    private readonly adapter: IWebSocketServerAdapter,
1✔
16
  ) {
17
    this.process
1✔
18
      .on('message', this.onMessage.bind(this))
19
      .on('SIGINT', this.onExit.bind(this))
20
      .on('SIGHUP', this.onExit.bind(this))
21
      .on('SIGTERM', this.onExit.bind(this))
22
      .on('uncaughtException', this.onError.bind(this))
23
      .on('unhandledRejection', this.onError.bind(this))
24
  }
25

26
  public run(): void {
27
    this.watchers = SettingsStatic.watchSettings()
×
28

29
    const port = process.env.PORT || process.env.RELAY_PORT || 8008
×
30
    this.adapter.listen(typeof port === 'number' ? port : Number(port))
×
31
  }
32

33
  private onMessage(message: { eventName: string; event: unknown }): void {
34
    this.adapter.emit(message.eventName, message.event)
×
35
  }
36

37
  private onError(error: Error) {
38
    if (error.name === 'TypeError' && error.message === "Cannot read properties of undefined (reading '__knexUid')") {
×
39
      logger.error(
×
40
        'Unable to acquire connection. Please increase DB_MAX_POOL_SIZE, DB_ACQUIRE_CONNECTION_TIMEOUT and tune postgresql.conf to make use of server\'s resources.'
41
      )
42
      return
×
43
    }
44
    logger.error('uncaught error:', error)
×
45
  }
46

47
  private onExit() {
48
    logger('exiting')
×
49
    this.close(() => {
×
50
      this.process.exit(0)
×
51
    })
52
  }
53

54
  public close(callback?: () => void) {
55
    logger('closing')
1✔
56
    if (Array.isArray(this.watchers)) {
1!
57
      for (const watcher of this.watchers) {
×
58
        watcher.close()
×
59
      }
60
    }
61
    this.adapter.close(async () => {
1✔
62
      await closeCacheClient()
1✔
63
      callback?.()
1✔
64
    })
65
    logger('closed')
1✔
66
  }
67
}
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