Skip to content

"Ready" Event Listener not defined in socketcluster-server type definitions #555

Description

@unicornlab-brylleg

It seems that the listener for the "ready" event of the AGServer type does not exist in the type definitions within \node_modules\@types\socketcluster-server\server.d.ts. Please see the below code snippet of this file:

listener(eventName: 'error'): ConsumableStream<{ error: Error }>;
listener(eventName: 'warning'): ConsumableStream<{ warning: Error }>;
listener(eventName: 'handshake'): ConsumableStream<{ socket: AGServerSocket }>;
listener(eventName: 'authenticationStateChange'): ConsumableStream<AGServer.AuthStateChangeData>;
listener(eventName: 'authentication'): ConsumableStream<AGServer.AuthenticationData>;
listener(eventName: 'deauthentication'): ConsumableStream<AGServer.DeauthenticationData>;
listener(eventName: 'badSocketAuthToken'): ConsumableStream<AGServer.BadSocketAuthTokenData>;
listener(eventName: 'connection'): ConsumableStream<AGServer.ConnectionData>;
listener(eventName: 'subscription'): ConsumableStream<AGServer.SubscriptionData>;
listener(eventName: 'unsubscription'): ConsumableStream<AGServer.UnsubscriptionData>;
listener(eventName: 'connectionAbort'): ConsumableStream<AGServer.ConnectionAbortData>;
listener(eventName: 'disconnection'): ConsumableStream<AGServer.DisconnectionData>;
listener(eventName: 'closure'): ConsumableStream<AGServer.ClosureData>;

However, according to the documentation of AGServer, there is a "ready" event defined:
'ready' | Emitted when the server is ready to accept connections.

I have checked the source code in \node_modules\socketcluster-server\server.js and it does indeed emit the "ready" event as per the below snippet:

if (this.brokerEngine.isReady) {
    this.isReady = true;
    this.emit('ready', {});
  } else {
    this.isReady = false;
    (async () => {
      await this.brokerEngine.listener('ready').once();
      this.isReady = true;
      this.emit('ready', {});
    })();
  }

Is it just me or is the type definitions file incomplete in this regard?

Package Versions:
"socketcluster-server": "^16.1.0"
"@types/socketcluster-server": "^15.0.4"
"socketcluster": "^16.0.2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions