Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
unicornlab-brylleg opened this issue Jan 4, 2022 · 1 comment

Comments

@unicornlab-brylleg
Copy link

unicornlab-brylleg commented Jan 4, 2022

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"

@jondubois
Copy link
Member

It's possible. You can make a pull request on the DefinitelyTyped repo on GitHub: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/socketcluster-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants