<commit_before>import nydus from 'nydus'
import path from 'path'
import fs from 'fs'
import cuid from 'cuid'
import getAddress from './lib/websockets/get-address'
import { createUserSockets, createClientSockets } from './lib/websockets/socket-groups'
import log from './lib/logging/logger'
import matchmakingStatusInstance from './lib/matchmaking/matchmaking-status-instance'

const apiHandlers = fs
  .readdirSync(path.join(__dirname, 'lib', 'wsapi'))
  .filter(filename => /\.(js|ts)$/.test(filename))
  .map(filename => require('./lib/wsapi/' + filename).default)

// dummy response object, needed for session middleware's cookie setting stuff
const dummyRes = {
  getHeader() {},
  setHeader() {},
}

class WebsocketServer {
  constructor(server, koaApp, sessionMiddleware) {
    this.httpServer = server
    this.koa = koaApp
    this.sessionWare = sessionMiddleware
    this.sessionLookup = new WeakMap()

    this.connectedUsers = 0
    this.nydus = nydus(this.httpServer, {
      allowRequest: async (info, cb) => await this.onAuthorization(info, cb),
    })
<commit_msg>Make a speculative fix for Websocket crashing (well, for the symptom, not the problem).<commit_after>import nydus from 'nydus'
import path from 'path'
import fs from 'fs'
import cuid from 'cuid'
import getAddress from './lib/websockets/get-address'
import { createUserSockets, createClientSockets } from './lib/websockets/socket-groups'
import log from './lib/logging/logger'
import matchmakingStatusInstance from './lib/matchmaking/matchmaking-status-instance'

const apiHandlers = fs
  .readdirSync(path.join(__dirname, 'lib', 'wsapi'))
  .filter(filename => /\.(js|ts)$/.test(filename))
  .map(filename => require('./lib/wsapi/' + filename).default)

// dummy response object, needed for session middleware's cookie setting stuff
const dummyRes = {
  getHeader() {},
  setHeader() {},
}

class WebsocketServer {
  constructor(server, koaApp, sessionMiddleware) {
    this.httpServer = server
    this.koa = koaApp
    this.sessionWare = sessionMiddleware
    this.sessionLookup = new WeakMap()

    this.connectedUsers = 0
    this.nydus = nydus(this.httpServer, {
      allowRequest: async (info, cb) => await this.onAuthorization(info, cb),
    })

    this.nydus.on('error', err => {
      log.error({ err }, 'nydus error')
    })

{'fraction_non_alphanumeric': 0.13126079447322972, 'fraction_numerical': 0.0008635578583765112, 'mean_word_length': 4.230248306997742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4292530', 'n_tokens_mistral': 720, 'n_tokens_neox': 707, 'n_words': 185}