{"record":{"id":"c2ae303ccf04a388","repo":"mongodb/node-mongodb-native","slug":"server-sent-message-compressed-using-an-unsupporte","errorCode":null,"errorMessage":"Server sent message compressed using an unsupported compressor. (Received compressor ID ${compressorID})","messagePattern":"Server sent message compressed using an unsupported compressor\\. \\(Received compressor ID (.+?)\\)","errorType":"exception","errorClass":"MongoDecompressionError","httpStatus":null,"severity":"error","filePath":"src/cmap/wire_protocol/compression.ts","lineNumber":120,"sourceCode":"      throw new MongoInvalidArgumentError(\n        `Unknown compressor ${options.agreedCompressor} failed to compress`\n      );\n    }\n  }\n}\n\n// Decompress a message using the given compressor\nexport async function decompress(\n  compressorID: number,\n  compressedData: Uint8Array\n): Promise<Uint8Array> {\n  if (\n    compressorID !== Compressor.snappy &&\n    compressorID !== Compressor.zstd &&\n    compressorID !== Compressor.zlib &&\n    compressorID !== Compressor.none\n  ) {\n    throw new MongoDecompressionError(\n      `Server sent message compressed using an unsupported compressor. (Received compressor ID ${compressorID})`\n    );\n  }\n\n  switch (compressorID) {\n    case Compressor.snappy: {\n      Snappy ??= loadSnappy();\n      return await Snappy.uncompress(compressedData, { asBuffer: true });\n    }\n    case Compressor.zstd: {\n      loadZstd();\n      if ('kModuleError' in zstd) {\n        throw zstd['kModuleError'];\n      }\n      return await zstd.decompress(compressedData);\n    }\n    case Compressor.zlib: {\n      return await zlibInflate(compressedData);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/cmap/wire_protocol/compression.ts#L102-L138","documentation":"Thrown by decompress() in the wire protocol layer when a server response arrives marked as OP_COMPRESSED but carries a compressorID byte outside the recognized set (0=none, 1=snappy, 2=zlib, 3=zstd). The driver cannot decode the payload because no handler exists for that ID, so the entire response is unusable. It surfaces as a MongoDecompressionError. This typically indicates byte corruption on the wire, a man-in-the-middle/proxy rewriting frames, or a server using a compressor the client driver version does not yet support.","triggerScenarios":"Occurs only when compression is enabled in client options (compressors: ['zlib'|'snappy'|'zstd']) AND the server agreed to compress AND a returned OP_COMPRESSED frame's compressorID byte at offset headerSize+8 is not 0,1,2, or 3. Fires inside decompressResponse -> decompress at src/cmap/wire_protocol/compression.ts:120 during response reading on any compressed command.","commonSituations":"A corporate proxy or load balancer (e.g. HAProxy with protobuf-aware rewriting, a debugging MITM) mangles MongoDB wire frames; running against a prerelease/newer server that introduced a new compressor before the driver shipped support; network hardware bit-flips; a stale connection pool reusing a socket after the server changed its compression config mid-session.","solutions":["Remove or empty the 'compressors' option in your MongoClientOptions so compression is not negotiated (fastest workaround).","Upgrade the mongodb driver to the latest version in case the compressor ID is newly supported.","Disable any proxy, sidecar, or packet inspector between the client and mongod/mongos and retest against the server directly.","Capture the traffic and confirm the server's hello response compressor list; if it advertises an ID the driver cannot handle, upgrade or reconfigure mongod.","Open a MongoDB server ticket if a stable server advertises a compressor ID absent from the driver's Compressor map."],"exampleFix":"// before\nconst client = new MongoClient(uri, { compressors: ['zstd'] });\n\n// after (disable compression to isolate the failure)\nconst client = new MongoClient(uri);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await collection.find({}).toArray();\n} catch (error) {\n  if (error instanceof MongoDecompressionError) {\n  }\n}","preventionTips":["Only enable compression against genuine mongod/mongos with no traffic-altering proxy.","Pin known-good snappy/zstd/zlib native dependency versions.","Keep driver and server versions within the supported compatibility matrix."],"tags":["network","compression","wire-protocol","configuration"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}