testRepliesSplitInsideACharacterReadAsSent
A reply read in chunks is decoded whole: a character split between two of them (a → in a definition's text) comes
as written, so the text keeps the length its references' offsets count.
import { HttpRemote } from "#codebase/tcmts/cli/sync"; import assert from "node:assert/strict"; import http from "node:http"; import type { AddressInfo } from "node:net"; export const testRepliesSplitInsideACharacterReadAsSent = async () => { const body = Buffer.from(JSON.stringify({ records: [{ sourceText: "`${a} → ${b}`" }] })); const cut = body.indexOf(Buffer.from("→")) + 1; const server = http.createServer((_req, res) => { res.writeHead(200, { "content-type": "application/json" }); res.write(body.subarray(0, cut)); setTimeout(() => res.end(body.subarray(cut)), 20); }); await new Promise<void>((r) => server.listen(0, "127.0.0.1", r)); try { const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`; const [rec] = await new HttpRemote(url).get(["h"]); assert.equal(rec!.sourceText, "`${a} → ${b}`"); } finally { server.close(); } }