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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
博客园 - 叶小钗
爱范儿
爱范儿
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
T
Tailwind CSS Blog
博客园 - 司徒正美
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell

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
fix(line): acknowledge webhooks before agent processing ·...
steipete · 2026-05-15 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai

1111
1212

### Fixes

1313
14+

- LINE: acknowledge signed webhook events before agent processing so slow model replies do not cause LINE `request_timeout` delivery failures. Fixes #65375. Thanks @myericho.

1415

- Codex/Lossless: keep Codex explicit compaction on native app-server threads while allowing Lossless through the context-engine slot; `openclaw doctor --fix` now migrates legacy `compaction.provider: "lossless-claw"` config to `plugins.slots.contextEngine`.

1516

- Gateway/approvals: treat `turnSourceTo` as optional in `canBridgeNoDeviceChatApprovalFromBackend`, matching the existing optional handling of `turnSourceAccountId` and `turnSourceThreadId`. Channels without a recipient concept (webchat, control-ui) leave `turnSourceTo` null on both the approval snapshot and the replay params, so the prior required-string check rejected every backend replay with `APPROVAL_CLIENT_MISMATCH`. Cross-channel replay is still gated by the required `turnSourceChannel` and `sessionKey` checks. Fixes #82132. (#82136) Thanks @ottodeng.

1617

- Cron: load runtime plugins before isolated cron model and delivery resolution so external channels can be selected for scheduled runs. (#82111) Thanks @medns.

Original file line numberDiff line numberDiff line change

@@ -42,7 +42,9 @@ openclaw plugins install ./path/to/local/line-plugin

4242

https://gateway-host/line/webhook

4343

```

4444
45-

The gateway responds to LINE's webhook verification (GET) and inbound events (POST).

45+

The gateway responds to LINE's webhook verification (GET) and acknowledges signed

46+

inbound events (POST) immediately after signature and payload validation; agent

47+

processing continues asynchronously.

4648

If you need a custom path, set `channels.line.webhookPath` or

4749

`channels.line.accounts.<id>.webhookPath` and update the URL accordingly.

4850
Original file line numberDiff line numberDiff line change

@@ -593,27 +593,25 @@ describe("line outbound sendPayload", () => {

593593

);

594594

});

595595
596-

it("declares receive ack policies for deferred LINE webhook acknowledgement", async () => {

596+

it("declares receive ack policies for immediate LINE webhook acknowledgement", async () => {

597597

const proofResults = await verifyChannelMessageReceiveAckPolicyAdapterProofs({

598598

adapterName: "line",

599599

adapter: linePlugin.message!,

600600

proofs: {

601601

after_receive_record: () => {

602+

expect(linePlugin.message?.receive?.defaultAckPolicy).toBe("after_receive_record");

602603

expect(linePlugin.message?.receive?.supportedAckPolicies).toContain(

603604

"after_receive_record",

604605

);

605606

},

606-

after_agent_dispatch: () => {

607-

expect(linePlugin.message?.receive?.defaultAckPolicy).toBe("after_agent_dispatch");

608-

},

609607

},

610608

});

611609
612610

expect(proofResults.find((result) => result.policy === "after_receive_record")?.status).toBe(

613611

"verified",

614612

);

615613

expect(proofResults.find((result) => result.policy === "after_agent_dispatch")?.status).toBe(

616-

"verified",

614+

"not_declared",

617615

);

618616

});

619617

});

Original file line numberDiff line numberDiff line change

@@ -357,6 +357,47 @@ describe("monitorLineProvider lifecycle", () => {

357357

secondMonitor.stop();

358358

});

359359
360+

it("acknowledges shared-path POST requests before matched event processing completes", async () => {

361+

const monitor = await monitorLineProvider({

362+

channelAccessToken: "token",

363+

channelSecret: "secret", // pragma: allowlist secret

364+

accountId: "default",

365+

config: {} as OpenClawConfig,

366+

runtime: {} as RuntimeEnv,

367+

});

368+
369+

let releaseWebhook: (() => void) | undefined;

370+

const bot = createLineBotMock.mock.results[0]?.value as {

371+

handleWebhook: ReturnType<typeof vi.fn>;

372+

};

373+

bot.handleWebhook.mockImplementation(

374+

async () =>

375+

await new Promise<void>((resolve) => {

376+

releaseWebhook = resolve;

377+

}),

378+

);

379+
380+

const route = requireRegisteredRoute();

381+

const payload = JSON.stringify({ events: [{ type: "message" }] });

382+

const signature = crypto.createHmac("SHA256", "secret").update(payload).digest("base64");

383+

const req = Object.assign(createMockIncomingRequest([payload]), {

384+

method: "POST",

385+

headers: { "x-line-signature": signature },

386+

}) as unknown as IncomingMessage;

387+

const res = createRouteResponse();

388+
389+

await route.handler(req, res);

390+
391+

expect(res.statusCode).toBe(200);

392+

expect(res.headersSent).toBe(true);

393+

expect(bot.handleWebhook).toHaveBeenCalledTimes(1);

394+

if (!releaseWebhook) {

395+

throw new Error("expected pending LINE webhook handler");

396+

}

397+

releaseWebhook();

398+

monitor.stop();

399+

});

400+
360401

it("rejects ambiguous shared-path webhook signatures", async () => {

361402

const firstMonitor = await monitorLineProvider({

362403

channelAccessToken: "first-token",

Original file line numberDiff line numberDiff line change

@@ -429,15 +429,20 @@ export async function monitorLineProvider(

429429

}

430430
431431

requestLifecycle.release();

432+

res.statusCode = 200;

433+

res.setHeader("Content-Type", "application/json");

434+

res.end(JSON.stringify({ status: "ok" }));

432435
433436

if (body.events && body.events.length > 0) {

434437

logVerbose(`line: received ${body.events.length} webhook events`);

435-

await match.target.bot.handleWebhook(body);

438+

void Promise.resolve()

439+

.then(() => match.target.bot.handleWebhook(body))

440+

.catch((err) => {

441+

match.target.runtime.error?.(

442+

danger(`line webhook dispatch failed: ${String(err)}`),

443+

);

444+

});

436445

}

437-
438-

res.statusCode = 200;

439-

res.setHeader("Content-Type", "application/json");

440-

res.end(JSON.stringify({ status: "ok" }));

441446

} catch (err) {

442447

if (isRequestBodyLimitError(err, "PAYLOAD_TOO_LARGE")) {

443448

res.statusCode = 413;

Original file line numberDiff line numberDiff line change

@@ -421,7 +421,7 @@ export const lineMessageAdapter = defineChannelMessageAdapter({

421421

},

422422

},

423423

receive: {

424-

defaultAckPolicy: "after_agent_dispatch",

425-

supportedAckPolicies: ["after_receive_record", "after_agent_dispatch"],

424+

defaultAckPolicy: "after_receive_record",

425+

supportedAckPolicies: ["after_receive_record"],

426426

},

427427

});

Original file line numberDiff line numberDiff line change

@@ -303,18 +303,20 @@ describe("LINE webhook shared POST contract", () => {

303303

);

304304
305305

it.each(sharedWebhookPostContractCases)(

306-

"$name returns 500 when event processing fails and does not acknowledge with 200",

306+

"$name acknowledges signed events before failed background processing is logged",

307307

async ({ invoke }) => {

308308

const result = await invoke({

309309

failWith: new Error("transient failure"),

310310

rawBody: JSON.stringify({ events: [{ type: "message" }] }),

311311

signed: true,

312312

});

313313
314-

expect(result.status).toBe(500);

315-

expect(result.body).toEqual({ error: "Internal server error" });

314+

expect(result.status).toBe(200);

315+

expect(result.body).toEqual({ status: "ok" });

316316

expect(result.dispatched).toHaveBeenCalledTimes(1);

317-

expect(result.runtimeError).toHaveBeenCalledTimes(1);

317+

await vi.waitFor(() => {

318+

expect(result.runtimeError).toHaveBeenCalledTimes(1);

319+

});

318320

},

319321

);

320322

});

@@ -436,7 +438,7 @@ describe("createLineNodeWebhookHandler", () => {

436438

expect(payload.events).toEqual([{ type: "message" }]);

437439

});

438440
439-

it("releases authenticated requests before event processing completes", async () => {

441+

it("acknowledges signed event requests before event processing completes", async () => {

440442

const rawBody = JSON.stringify({ events: [{ type: "message" }] });

441443

let releaseAuthenticated: (() => void) | undefined;

442444

const bot = {

@@ -465,14 +467,14 @@ describe("createLineNodeWebhookHandler", () => {

465467

expect(bot.handleWebhook).toHaveBeenCalledTimes(1);

466468

});

467469
468-

expect(res.headersSent).toBe(false);

470+

await request;

471+
472+

expect(res.statusCode).toBe(200);

473+

expect(res.headersSent).toBe(true);

469474

if (!releaseAuthenticated) {

470475

throw new Error("Expected LINE authenticated request release callback to be initialized");

471476

}

472477

releaseAuthenticated();

473-

await request;

474-
475-

expect(res.statusCode).toBe(200);

476478

});

477479
478480

it("returns 400 for invalid JSON payload even when signature is valid", async () => {

Original file line numberDiff line numberDiff line change

@@ -29,6 +29,10 @@ export async function readLineWebhookRequestBody(

2929
3030

type ReadBodyFn = (req: IncomingMessage, maxBytes: number, timeoutMs?: number) => Promise<string>;

3131
32+

function logLineWebhookDispatchError(runtime: RuntimeEnv | undefined, err: unknown): void {

33+

runtime?.error?.(danger(`line webhook dispatch failed: ${String(err)}`));

34+

}

35+
3236

export function createLineNodeWebhookHandler(params: {

3337

channelSecret: string;

3438

bot: { handleWebhook: (body: webhook.CallbackRequest) => Promise<void> };

@@ -108,22 +112,23 @@ export function createLineNodeWebhookHandler(params: {

108112

id: `${Date.now()}:line:webhook`,

109113

channel: "line",

110114

message: body,

111-

ackPolicy: body.events?.length ? "after_agent_dispatch" : "after_receive_record",

115+

ackPolicy: "after_receive_record",

112116

onAck: () => {

113117

res.statusCode = 200;

114118

res.setHeader("Content-Type", "application/json");

115119

res.end(JSON.stringify({ status: "ok" }));

116120

},

117121

});

118122
119-

if (body.events && body.events.length > 0) {

120-

logVerbose(`line: received ${body.events.length} webhook events`);

121-

await params.bot.handleWebhook(body);

123+

if (receiveContext.shouldAckAfter("receive_record")) {

124+

await receiveContext.ack();

122125

}

123126
124-

const ackStage = body.events?.length ? "agent_dispatch" : "receive_record";

125-

if (receiveContext.shouldAckAfter(ackStage)) {

126-

await receiveContext.ack();

127+

if (body.events && body.events.length > 0) {

128+

logVerbose(`line: received ${body.events.length} webhook events`);

129+

void Promise.resolve()

130+

.then(() => params.bot.handleWebhook(body))

131+

.catch((err) => logLineWebhookDispatchError(params.runtime, err));

127132

}

128133

} catch (err) {

129134

await receiveContext?.nack(err);

Original file line numberDiff line numberDiff line change

@@ -32,6 +32,10 @@ function parseWebhookBody(rawBody?: string | null): webhook.CallbackRequest | nu

3232

return parseLineWebhookBody(rawBody);

3333

}

3434
35+

function logLineWebhookDispatchError(runtime: RuntimeEnv | undefined, err: unknown): void {

36+

runtime?.error?.(danger(`line webhook dispatch failed: ${String(err)}`));

37+

}

38+
3539

export function createLineWebhookMiddleware(

3640

options: LineWebhookOptions,

3741

): (req: Request, res: Response, _next: NextFunction) => Promise<void> {

@@ -75,20 +79,21 @@ export function createLineWebhookMiddleware(

7579

id: `${Date.now()}:line:webhook`,

7680

channel: "line",

7781

message: body,

78-

ackPolicy: body.events?.length ? "after_agent_dispatch" : "after_receive_record",

82+

ackPolicy: "after_receive_record",

7983

onAck: () => {

8084

res.status(200).json({ status: "ok" });

8185

},

8286

});

8387
84-

if (body.events && body.events.length > 0) {

85-

logVerbose(`line: received ${body.events.length} webhook events`);

86-

await onEvents(body);

88+

if (receiveContext.shouldAckAfter("receive_record")) {

89+

await receiveContext.ack();

8790

}

8891
89-

const ackStage = body.events?.length ? "agent_dispatch" : "receive_record";

90-

if (receiveContext.shouldAckAfter(ackStage)) {

91-

await receiveContext.ack();

92+

if (body.events && body.events.length > 0) {

93+

logVerbose(`line: received ${body.events.length} webhook events`);

94+

void Promise.resolve()

95+

.then(() => onEvents(body))

96+

.catch((err) => logLineWebhookDispatchError(runtime, err));

9297

}

9398

} catch (err) {

9499

await receiveContext?.nack(err);