{"id":"ce45777b8811d4fd","repo":"mongodb/node-mongodb-native","slug":"servermonitoringmode-must-be-one-of-auto-poll","errorCode":null,"errorMessage":"serverMonitoringMode must be one of `auto`, `poll`, or `stream`","messagePattern":"serverMonitoringMode must be one of `auto`, `poll`, or `stream`","errorType":"exception","errorClass":"MongoParseError","httpStatus":null,"severity":"error","filePath":"src/connection_string.ts","lineNumber":1093,"sourceCode":"  retryReads: {\n    default: true,\n    type: 'boolean'\n  },\n  retryWrites: {\n    default: true,\n    type: 'boolean'\n  },\n  runtimeAdapters: {\n    type: 'record'\n  },\n  serializeFunctions: {\n    type: 'boolean'\n  },\n  serverMonitoringMode: {\n    default: 'auto',\n    transform({ values: [value] }) {\n      if (!Object.values(ServerMonitoringMode).includes(value as any)) {\n        throw new MongoParseError(\n          'serverMonitoringMode must be one of `auto`, `poll`, or `stream`'\n        );\n      }\n      return value;\n    }\n  },\n  serverSelectionTimeoutMS: {\n    default: 30000,\n    type: 'uint'\n  },\n  servername: {\n    type: 'string'\n  },\n  socketTimeoutMS: {\n    // TODO(NODE-6491): deprecated: 'Please use timeoutMS instead',\n    default: 0,\n    type: 'uint'\n  },","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/connection_string.ts#L1075-L1111","documentation":"`serverMonitoringMode` selects the SDAM health-check strategy and must be one of the `ServerMonitoringMode` enum values: `auto`, `poll`, or `stream`. Any other value throws at src/connection_string.ts:1093.","triggerScenarios":"`{ serverMonitoringMode: 'fast' }`; `{ serverMonitoringMode: 'websocket' }`; `{ serverMonitoringMode: 'polling' }`; `{ serverMonitoringMode: 'async' }`.","commonSituations":"Guessing mode names; using 'polling' instead of 'poll'; setting it to optimize latency without checking the enum.","solutions":["Use exactly 'auto', 'poll', or 'stream'","Omit the option to use the default 'auto'","Reference the ServerMonitoringMode enum instead of hardcoding strings"],"exampleFix":"// before\nnew MongoClient(uri, { serverMonitoringMode: 'polling' });\n// after\nnew MongoClient(uri, { serverMonitoringMode: 'poll' });","handlingStrategy":"validation","validationCode":"import { ServerMonitoringMode } from 'mongodb';\nconst VALID = new Set(Object.values(ServerMonitoringMode));\nif (options.serverMonitoringMode != null && !VALID.has(options.serverMonitoringMode)) {\n  throw new TypeError('serverMonitoringMode must be auto, poll, or stream');\n}","typeGuard":"import { ServerMonitoringMode } from 'mongodb';\nfunction isServerMonitoringMode(v) {\n  return Object.values(ServerMonitoringMode).includes(v);\n}","tryCatchPattern":null,"preventionTips":["Use exactly 'auto', 'poll', or 'stream'","Reference the ServerMonitoringMode enum instead of hardcoding strings","Omit the option for the default 'auto'"],"tags":["sdam","configuration","options"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}