-
Type:
Story
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:OS:
node.js / npm versions:
Additional info:
Use Case
As a Data Explorer Engineer
I want the connection attempt to fail fast when encountering non-retryable errors during the initial connection process
So that I do not spend resources on automatic reconnect attempts by the client
User Experience
- When a connection encounters a non-retryable error (like "Cluster is not in a valid state" with close code 1008) during the initial connection attempt, the connection should fail immediately and close the MongoClient to prevent the driver's continuous monitoring and retry attempts.
Risks/Unknowns
- The non-retryable error handling added in compass-web may have stopped working or never fully covered the initial connection phase
- The heartbeat failed listener isn't set up until after successful connection, so errors during initial connection aren't caught
- Need to ensure we don't break other connection scenarios while implementing fail-fast behavior
- We are going to hard code a list of codes in the client that needs to remain in sync with server implementation
- Performance impact should be negligible
Acceptance Criteria
Implementation Requirements
- Add error handling for non-retryable errors (close code 1008 and others) during the initial connection process, close the MongoClient
- Follow patterns from devtools shared connect package for handling fail-fast during connection process
Testing Requirements
- Add an int/unit mocking test to devtools connect that handles the error we expect to be thrown from the tls polyfill in the scenarios we're trying to handle
- Add new synthetic test that covers the e2e error toast behavior we expect from the improvement. We should expect to see the error much sooner than 30seconds (serverSelectionTimeoutMS)
References
- Original non-retryable error handling: https://github.com/mongodb-js/compass/blob/a9ea81e89378d6205ae664f858a23c7135fe3a46/packages/compass-connections/src/stores/connections-store-redux.ts#L1410-L1419
- Sentry trace showing issue: https://mongodb-org.sentry.io/dashboards/trace/d240e2adba4a499bb67791de3fad6629/?dashboardId=142094&environment=prod&fov=17642.443549603224%2C60.02953439950943&node=span-3627092fbd124f13&project=4505240668733440&project=4509401391628288&source=dashboards&statsPeriod=3d&tamp=1756854234&widgetId=1150500
- PR with listener addition: https://github.com/mongodb-js/compass/pull/6598/files#diff-018a2f2c6c0aff913162a6568095ab43fb5d67249a66a9f30ae26c4ea61d3daaR1729