Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

WorkspaceProxy wakes Durable Objects via idFromString(), clearing ctx.id.name for Agents/Lifecycle

未关闭
#243 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@aron-cf 已经在做这个了。

开始于 2026年10月15日。

  • #244 来自 @aron-cf —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

bug
Describe the bug

When a Durable Object using cloudflare/agents (Lifecycle / Agent / OpenCodeHarness) is paired with @cloudflare/computer's ContainerBackend (or WorkerShellBackend), WorkspaceProxy.#hostStub() and WorkspaceServiceProxy.#hostStub() always resolve the host Durable Object via ns.get(ns.idFromString(id)).

Because a running container outlives Durable Object idle evictions, restarts, and Worker deployments, computerd reconnecting over WorkspaceProxy (/api) is frequently the first caller to wake the Durable Object from a cold start.

In Cloudflare Workers, instantiating a Durable Object via idFromString() does not populate ctx.id.name, so ctx.id.name remains undefined for the entire lifetime of that in-memory Durable Object instance (which stays pinned while the /api WebSocket is open). Any subsequent Lifecycle startup on that instance fails with:

Error: <Class> could not determine its Durable Object name. Address it with idFromName() or getByName().
Expected behavior

WorkspaceRef, WorkspaceProxyProps, and WorkspaceServiceProxyProps should accept an optional name?: string (e.g. this.ctx.id.name) so WorkspaceProxy and WorkspaceServiceProxy resolve the target Durable Object via ns.idFromName(name) (when ns.idFromName(name).toString() === id), preserving ctx.id.name across cold wakes triggered by container callbacks.

A tested patch with workerd unit tests in packages/computer/tests/proxy.test.ts is available at:
https://github.com/4nkitd/computer/commit/efb5ded

Steps to reproduce
  1. Create a Durable Object class using withWorkspaceContainer(Base), ContainerBackend, and Lifecycle.install(this) (from agents/lifecycle).
  2. Address the Durable Object via env.Agent.getByName("main") and start a container command so computerd connects back via WorkspaceProxy.
  3. Redeploy the Worker or let the Durable Object evict while the container remains running so computerd reconnects via WorkspaceProxy (ns.get(ns.idFromString(id))) before the next external getByName("main") request.
  4. Trigger lifecycle.start() on the woken Durable Object; ctx.id.name is undefined and Lifecycle throws could not determine its Durable Object name.
Environment
  • @cloudflare/computer: 0.5.1
  • agents: 0.28.1
  • wrangler: 4.151.0 (compatibility_date: 2026-10-15)
主要语言
TypeScript
星标
9.6k
派生
558
平均合并
1 天 19 小时
30 天内合并 PR
52

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudflare/computer 的其他 Issue

查看 cloudflare/computer 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。