SocketCluster / SocketCluster/socketcluster

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

Open
#555 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.2k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the AGServer listener declarations in node_modules/@types/socketcluster-server/server.d.ts and compare them with the documented and emitted "ready" event in socketcluster-server/server.js. Add the missing type definition for that event, then verify the package's type checks or tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.