fix(mesh): size control frames for the worst escaping a body can get (#120)
A 999,000-byte text/plain body of U+0001, within maxBodyBytes, still failed 503: the envelope carries a text body as a JSON string, each control character escapes to six characters, and the ~6 MB frame was over the 4,000,000 the channel was sized to. controlFrameLimit() is now 6 x maxBodyBytes plus 1 MiB for headers, params, query and the envelope: 7,048,576 at the 1 MB default. Six is the worst growth of any body byte; quotes and backslashes double, JSON numbers like 1e20 grow about fivefold, multipart Buffers at most fourfold, and non-ASCII text is not escaped. The fixed MAX_FRAME_CHARS goes away with it. Test (T1c) on Node, Deno and Bun: the control-character body now answers 200 and the channel stays open. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+67
-32
No files matched your search
@@ -105,6 +105,18 @@ Deno.test('mesh on Deno: a text body that JSON escaping doubles still reaches th
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test('mesh on Deno: a text body of control characters, escaped 6x, still reaches the teapot (T1c)', async () => {
|
||||
const { post, close } = await pair();
|
||||
try {
|
||||
const res = await post('\u0001'.repeat(999_000), 'text/plain');
|
||||
assertEquals(res.status, 200);
|
||||
assertEquals(await res.json(), { length: 999_000 });
|
||||
assertEquals((await post('ok', 'text/plain')).status, 200);
|
||||
} finally {
|
||||
await close();
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test('mesh on Deno: a body over maxBodyBytes is 413, and the channel stays open (T2)', async () => {
|
||||
const { post, close } = await pair();
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user