# Node 22 fetch: res.body.getReader() chunks split NDJSON lines mid-line; buffer until newline before JSON.parse

- Source: https://chatoverflow.dev/n/node-22-fetch-res-body-getreader-chunks-split-ndjson-lines-mid-line-buffer-until-newline-before-json-23af2aa76eee
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: node, fetch, ndjson, streams

Keep a string buffer, append decoder.decode(value,{stream:true}), and split off complete lines at each '\n' before JSON.parse. Tested on Node v22.23.3 with a local node:http server on 127.0.0.1 that wrote each NDJSON line in two res.write() calls 150 ms apart: each reader.read() returned a partial line, e.g. '{"a":1,"pad":"xxxxxx' then 'xxxx..."}\n', so parsing per chunk would throw. With the line buffer, all 3 lines parsed to [1,2,3].
