{"id":"613035d4c3504556","repo":"redis/node-redis","slug":"unknown-resp-type-type-string-fromcharcode-t","errorCode":null,"errorMessage":"Unknown RESP type ${type} \"${String.fromCharCode(type)}\"","messagePattern":"Unknown RESP type (.+?) \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/client/lib/RESP/decoder.ts","lineNumber":206,"sourceCode":"        return this.#handleDecodedValue(\n          this.onReply,\n          this.#decodeSet(this.getTypeMapping(), chunk)\n        );\n\n      case RESP_TYPES.MAP:\n        return this.#handleDecodedValue(\n          this.onReply,\n          this.#decodeMap(this.getTypeMapping(), chunk)\n        );\n\n      case RESP_TYPES.PUSH:\n        return this.#handleDecodedValue(\n          this.onPush,\n          this.#decodeArray(PUSH_TYPE_MAPPING, chunk)\n        );\n\n      default:\n        throw new Error(`Unknown RESP type ${type} \"${String.fromCharCode(type)}\"`);\n    }\n  }\n\n  #handleDecodedValue(cb, value) {\n    if (typeof value === 'function') {\n      this.#next = this.#continueDecodeValue.bind(this, cb, value);\n      return true;\n    }\n\n    cb(value);\n    return false;\n  }\n\n  #continueDecodeValue(cb, next, chunk) {\n    this.#next = undefined;\n    return this.#handleDecodedValue(cb, next(chunk));\n  }\n","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/redis/node-redis/blob/bb5beb56578573910e2ee8f39681edc214c41398/packages/client/lib/RESP/decoder.ts#L188-L224","documentation":"Thrown by the RESP3 decoder's top-level dispatch (#decodeTypeValue) when the leading type byte of a reply is not one of the recognized RESP type markers (_, #, :, (, ,, +, $, =, -, !, *, ~, %, >). It means the byte stream the client received does not conform to any RESP type the decoder knows. The message includes the raw byte value and its ASCII rendering to aid diagnosis.","triggerScenarios":"Connecting to something that is not a Redis/RESP server (e.g. an HTTP endpoint, a MySQL server) on the Redis port; TLS/plain-text mismatch where binary handshake bytes are interpreted as RESP; a proxy/load-balancer injecting a non-RESP banner or error page; severe network corruption truncating the stream mid-frame so the next reply starts on an arbitrary byte.","commonSituations":"Pointing `redis://` at a `rediss://` (TLS) port or vice-versa; a sidecar/proxy (Envoy, HAProxy in wrong mode) returning a plaintext error; Redis behind a sentinel/cluster router that speaks a different handshake on the same port; ATO/server returning an HTML 502 page; version skew where a server emits an experimental RESP type not in the client's RESP_TYPES table.","solutions":["Verify the endpoint is actually a Redis (or RESP-speaking) server: `redis-cli -h <host> -p <port> PING`.","Check the TLS setting matches the port: use `rediss://` (or socket.tls=true) only for TLS endpoints, `redis://` for plain.","Inspect the first bytes received from the port (e.g. `openssl s_client` / `nc`) to confirm they start with a RESP type char like `+`, `-`, `$`, `*`, `:`.","Remove or correctly configure any proxy in front of Redis, or switch it to TCP passthrough.","Upgrade the client if the server is a newer Redis emitting a RESP3 type not yet supported by this client version."],"exampleFix":"// before\ncreateClient({ url: 'redis://my-redis:6379' }) // but server requires TLS\n\n// after\ncreateClient({ url: 'rediss://my-redis:6379' })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await client.connect();\n  await client.ping();\n} catch (err) {\n  if (err instanceof Error && /Unknown RESP type/.test(err.message)) {\n    // the endpoint is not speaking RESP or TLS/plain is mismatched; check the URL scheme and port\n  }\n  throw err;\n}","preventionTips":["Verify the endpoint speaks RESP before pointing the client at it.","Keep the TLS scheme (rediss://) aligned with the port's actual transport.","Avoid putting non-RESP proxies in front of Redis, or set them to raw TCP passthrough."],"tags":["resp","network","protocol","tls"],"analyzedSha":"bb5beb56578573910e2ee8f39681edc214c41398","analyzedAt":"2026-08-03T19:09:15.686Z","schemaVersion":2}