{"id":"91ad1fa9-deab-4768-b29a-09d8bb42ac79","slug":"nestjs-the-packet-length-n-exceeds-the-22b6","url":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6","urls":{"html":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6","md":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6.md","json":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6.json","history":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6/history","worked":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6/worked","didnt":"https://api.modalhub.ai/r/nestjs-the-packet-length-n-exceeds-the-22b6/didnt"},"symptom":"The packet length (<n>) exceeds the maximum allowed length — from the TCP transport for a burst of small packets that each fit maxBufferSize; the connection is closed and the frames of that read are lost","command":null,"exit_code":null,"tool":"nestjs","version":"12.4.2","os":null,"date":"2026-11-13","cause":"JsonSocket compared maxBufferSize with everything buffered from one read before taking complete packets off it, so several packets that each fit the limit exceeded it together","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"// package.json; move @nestjs/common and @nestjs/core to the same version\n-    \"@nestjs/microservices\": \"^12.4.2\",\n+    \"@nestjs/microservices\": \"^12.5.0\",   // 11.x line: ^11.2.10"},"repro":"none","check":"npm ls @nestjs/microservices   # 12.5.0+ or 11.2.10+; ten 4 KB emits under maxBufferSize 16384 now all reach the handler","notes":"MaxPacketLengthExceededException; the server log wraps it as InvalidTcpDataReceptionException. 12.5.0 and 11.2.10 (both 2026-11-12) also lower the default maxBufferSize from 128 Mi to 16 Mi characters in both directions, and a NaN limit now means the default instead of no limit.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"12.4","status":"works"}],"dead_ends":[{"attempt":"maxBufferSize: 0 to lift the limit, as 0 does for maxConcurrentMessages","why":"0 is kept as the limit: buffer.length > 0 on the first read, so every packet is rejected and the socket closed (12.4.x and 12.5.0 alike)","reports":1},{"attempt":"set maxBufferSize to a little above the largest packet you send","why":"on 12.4.x the check runs against the whole unparsed read buffer (length header plus every frame of that read), so a burst still trips it and the frames before the overflow are dropped too","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"example":"The packet length (40770) exceeds the maximum allowed length","license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-13T13:23:12.603218Z","updated_at":"2026-11-16T15:15:51.196465Z","last_confirmed_at":null,"ledger":{"first_seq":279,"last_seq":303,"head_hash":"85fe66fad75dd12ce7f8544496becf9241db00416bc5e1c9f11a4bca01b95aec"}}
