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

[adapter]: Add option to fetchSockets that returns results even if some nodes didn't respond #4995

Open
timsauvageot opened this issue Apr 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@timsauvageot
Copy link

Is your feature request related to a problem? Please describe.
Hey there,
the current implementation of fetchSockets in ClusterAdapterWithHeartbeat only resolves if a response was received from all cluster nodes. In some situations this isn't needed and an optimistic response would suffice (i.e. return all responses of nodes that are alive).
Nodes that go down (based on logic inside of cleanupTimer) are also not removed from the missingUids list of any pending requests (customRequests). So even when it's detected that a node is down and therefore can't return a response, an error is still thrown.

Describe the solution you'd like

  • Add optional flag to fetchSockets which causes the function to resolve with the values of all nodes that answered.
  • remove id of nodes that were detected as not alive in cleanUp timer from missingUids of customRequests

Describe alternatives you've considered
An optional flag could also be set on ClusterAdapterOptions however the config would then need to be added as union type for existing adapters (e.g. change createAdapter(pool: Pool, opts: Partial<PostgresAdapterOptions> = {})
to createAdapter(pool: Pool, opts: Partial<PostgresAdapterOptions & ClusterAdapterOptions> = {}) otherwise the value cannot be set.

Additional context
I already opened an issue in the adapter repository but didn't get a response there.
I'd be happy to implement the changes myself if there aren't any concerns.

@timsauvageot timsauvageot added the enhancement New feature or request label Apr 17, 2024
@darrachequesne
Copy link
Member

Hi!

With emitWithAck(), we attach the incomplete response array to the error, do you think it would make sense to do the same with fetchSockets()?

return new Promise((resolve, reject) => {
args.push((err, responses) => {
if (err) {
err.responses = responses;
return reject(err);
} else {
return resolve(responses);
}
});
this.emit(ev, ...(args as any[] as EventParams<EmitEvents, Ev>));
});

remove id of nodes that were detected as not alive in cleanUp timer from missingUids of customRequests

I think this was implemented in socketio/socket.io-adapter@0e23ff0, included in socket.io-adapter@2.5.3. Is that what you had in mind?

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

No branches or pull requests

2 participants