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

推荐订阅源

A
About on SuperTechFans
G
Google Developers Blog
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
小众软件
小众软件
月光博客
月光博客
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
The Cloudflare Blog
博客园_首页
美团技术团队
大猫的无限游戏
大猫的无限游戏
B
Blog
IT之家
IT之家
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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(sdk): reject work after client close · openclaw/openc...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

@@ -327,8 +327,10 @@ export class OpenClaw {

327327

});

328328

private readonly replayByRunId = new Map<string, OpenClawEvent[]>();

329329

private connected = false;

330+

private closed = false;

330331

private eventPumpPromise: Promise<void> | null = null;

331332

private eventPumpReady: Promise<void> | null = null;

333+

private closePromise: Promise<void> | null = null;

332334333335

constructor(options: OpenClawOptions = {}) {

334336

this.transport =

@@ -351,24 +353,45 @@ export class OpenClaw {

351353

}

352354353355

async connect(): Promise<void> {

356+

this.assertOpen();

354357

if (this.connected) {

355358

await this.startEventPump();

359+

this.assertOpen();

356360

return;

357361

}

358362

if (isConnectableTransport(this.transport)) {

359363

await this.transport.connect();

360364

}

365+

this.assertOpen();

361366

this.connected = true;

362367

await this.startEventPump();

368+

this.assertOpen();

363369

}

364370365371

async close(): Promise<void> {

366-

await this.transport.close?.();

367-

await this.eventPumpPromise?.catch(() => {});

368-

this.normalizedEvents.close();

369-

this.eventPumpPromise = null;

370-

this.eventPumpReady = null;

371-

this.connected = false;

372+

if (this.closePromise) {

373+

return await this.closePromise;

374+

}

375+

if (this.closed) {

376+

return;

377+

}

378+

this.closed = true;

379+

this.closePromise = (async () => {

380+

try {

381+

await this.transport.close?.();

382+

await this.eventPumpPromise?.catch(() => {});

383+

} finally {

384+

this.normalizedEvents.close();

385+

this.eventPumpPromise = null;

386+

this.eventPumpReady = null;

387+

this.connected = false;

388+

}

389+

})();

390+

try {

391+

await this.closePromise;

392+

} finally {

393+

this.closePromise = null;

394+

}

372395

}

373396374397

async request<T = unknown>(

@@ -377,6 +400,7 @@ export class OpenClaw {

377400

options?: GatewayRequestOptions,

378401

): Promise<T> {

379402

await this.connect();

403+

this.assertOpen();

380404

return await this.transport.request<T>(method, params, options);

381405

}

382406

@@ -392,13 +416,21 @@ export class OpenClaw {

392416

}

393417394418

rawEvents(filter?: (event: GatewayEvent) => boolean): AsyncIterable<GatewayEvent> {

419+

this.assertOpen();

395420

return this.transport.events(filter);

396421

}

397422423+

private assertOpen(): void {

424+

if (this.closed) {

425+

throw new Error("OpenClaw SDK client is closed");

426+

}

427+

}

428+398429

private async *iterateEvents(

399430

filter?: (event: OpenClawEvent) => boolean,

400431

): AsyncIterable<OpenClawEvent> {

401432

await this.connect();

433+

this.assertOpen();

402434

for await (const event of this.normalizedEvents.stream(filter)) {

403435

yield event;

404436

}

@@ -409,6 +441,7 @@ export class OpenClaw {

409441

filter?: (event: OpenClawEvent) => boolean,

410442

): AsyncIterable<OpenClawEvent> {

411443

await this.connect();

444+

this.assertOpen();

412445

const replayEvents = this.replaySnapshot(runId);

413446

let hasCanonicalAssistantRunEvent = replayEvents.some(isAssistantRunEvent);

414447

let hasTerminalRunEvent = replayEvents.some(isTerminalRunEvent);