惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
U
Unit 42
腾讯CDC
D
Docker
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
I
InfoQ
Jina AI
Jina AI
爱范儿
爱范儿
宝玉的分享
宝玉的分享
博客园 - Franky
G
Google Developers Blog
P
Proofpoint News Feed

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten http body limit error assertions · openclaw...
shakkernerd · 2026-05-11 · via Recent Commits to openclaw:main

@@ -4,7 +4,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest";

44

import { createMockServerResponse } from "../test-utils/mock-http-response.js";

55

import {

66

installRequestBodyLimitGuard,

7-

isRequestBodyLimitError,

7+

RequestBodyLimitError,

8+

type RequestBodyLimitErrorCode,

89

readJsonBodyWithLimit,

910

readRequestBodyWithLimit,

1011

} from "./http-body.js";

@@ -19,6 +20,37 @@ async function waitForMicrotaskTurn(): Promise<void> {

1920

await new Promise<void>((resolve) => queueMicrotask(resolve));

2021

}

212223+

async function expectRequestBodyLimitError(

24+

promise: Promise<unknown>,

25+

expected: {

26+

code: RequestBodyLimitErrorCode;

27+

message: string;

28+

statusCode: number;

29+

},

30+

) {

31+

try {

32+

await promise;

33+

} catch (error) {

34+

expect(error).toBeInstanceOf(RequestBodyLimitError);

35+

if (!(error instanceof RequestBodyLimitError)) {

36+

throw error;

37+

}

38+

expect({

39+

name: error.name,

40+

message: error.message,

41+

code: error.code,

42+

statusCode: error.statusCode,

43+

}).toEqual({

44+

name: "RequestBodyLimitError",

45+

message: expected.message,

46+

code: expected.code,

47+

statusCode: expected.statusCode,

48+

});

49+

return;

50+

}

51+

throw new Error("Expected request body reader to reject");

52+

}

53+2254

async function expectReadPayloadTooLarge(params: {

2355

chunks?: string[];

2456

headers?: Record<string, string>;

@@ -29,8 +61,10 @@ async function expectReadPayloadTooLarge(params: {

2961

headers: params.headers,

3062

emitEnd: false,

3163

});

32-

await expect(readRequestBodyWithLimit(req, { maxBytes: params.maxBytes })).rejects.toMatchObject({

64+

await expectRequestBodyLimitError(readRequestBodyWithLimit(req, { maxBytes: params.maxBytes }), {

65+

code: "PAYLOAD_TOO_LARGE",

3366

message: "PayloadTooLarge",

67+

statusCode: 413,

3468

});

3569

await waitForMicrotaskTurn();

3670

expect(req.__unhandledDestroyError).toBeUndefined();

@@ -212,9 +246,11 @@ describe("http body limits", () => {

212246

it("timeout surfaces typed error when timeoutMs is clamped", async () => {

213247

const req = createMockRequest({ emitEnd: false });

214248

const promise = readRequestBodyWithLimit(req, { maxBytes: 128, timeoutMs: 0 });

215-

await expect(promise).rejects.toSatisfy((error: unknown) =>

216-

isRequestBodyLimitError(error, "REQUEST_BODY_TIMEOUT"),

217-

);

249+

await expectRequestBodyLimitError(promise, {

250+

code: "REQUEST_BODY_TIMEOUT",

251+

message: "RequestBodyTimeout",

252+

statusCode: 408,

253+

});

218254

expect(req.__unhandledDestroyError).toBeUndefined();

219255

});

220256

@@ -231,8 +267,10 @@ describe("http body limits", () => {

231267

const req = createMockRequest({ emitEnd: false });

232268

const promise = readRequestBodyWithLimit(req, { maxBytes: 128 });

233269

queueMicrotask(() => req.emit("close"));

234-

await expect(promise).rejects.toSatisfy((error: unknown) =>

235-

isRequestBodyLimitError(error, "CONNECTION_CLOSED"),

236-

);

270+

await expectRequestBodyLimitError(promise, {

271+

code: "CONNECTION_CLOSED",

272+

message: "RequestBodyConnectionClosed",

273+

statusCode: 400,

274+

});

237275

});

238276

});