socketio / socketio/socket.io

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

Open
#4,995 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

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.

Contributor guide

Open the contributing guide

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

Start at fetchSockets in ClusterAdapterWithHeartbeat and trace cleanupTimer, customRequests, and missingUids. Compare ClusterAdapterOptions with the createAdapter and PostgresAdapterOptions examples; done means an optional fetchSockets mode returns responses from answering nodes and cleanup removes detected-dead node IDs from pending requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.