[miniflare] A Durable Object that calls a local Artifacts binding cannot be evicted
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with packages/miniflare/src/workers/artifacts/wrapped-binding.worker.ts and compare its result handling with the reproduction linked in the issue. Check the Artifacts specs and the reproduction’s eviction test, which calls evictDurableObject(stub) after list(). Done means a disposed list() result no longer prevents eviction; the issue reports that a fix also needs to handle file results and failed get calls.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
miniflare5.20261117.0-betaworkerd1.20261117.1@cloudflare/vitest-plugin1.8.3wrangler4.163.0vitest5.1.0- Node v26.10.0, pnpm 12.7.0, Git 2.43.0
- Linux x64 for the reproduction. I first saw the same timeout in a larger project on macOS.
Please provide a link to a minimal reproduction
https://github.com/nodnarbnitram/miniflare-artifacts-evict-repro
Describe the Bug
After a Durable Object calls a method of a local Artifacts binding, the object can no longer be evicted, even when it disposes the result of the call. In a test with @cloudflare/vitest-plugin, await evictDurableObject(stub) never settles, and the test times out. The same code is evicted on miniflare 5.20261109.0-beta.
Steps (the reproduction does exactly this):
- A Worker has an
artifactsbinding withoutremote, and a Durable Object. - A method of the Durable Object runs
const result = await this.env.ARTIFACTS.list(); result[Symbol.dispose]?.();. - A test calls that method on a stub, then
await evictDurableObject(stub).
What happens, with three tests that each call one method and then evict the object:
miniflare |
A: no Artifacts call | B: list(), result disposed |
C: list(), result not disposed |
|---|---|---|---|
| 5.20261117.0-beta | passes | times out | times out |
5.20261109.0-beta (with workerd 1.20261109.1) |
passes | passes | times out |
What I expect: test B passes on 5.20261117.0-beta, as it does on 5.20261109.0-beta. A caller that disposes its results can be evicted.
Cause, as far as I can tell: since #16771 a local Artifacts binding is a wrapped binding. packages/miniflare/src/workers/artifacts/wrapped-binding.worker.ts reads each RPC result of the namespace service with unwrap(...) and returns only the value, so the caller has nothing to dispose, and the wrapper never disposes the result itself. The one result that it does dispose is a get that succeeds, when the caller disposes the repository handle. A get that fails throws inside unwrap before a disposer is set. The wrapper runs in the caller's isolate (its header comment says so), so the results that are never disposed belong to the Durable Object that made the call.
A fix that works for me: in the wrapper, dispose each result after its value is read (a file result only after its body is read), and dispose a failed get before the error is thrown. With that change, all three tests of the reproduction pass on 5.20261117.0-beta, and the Artifacts specs of Miniflare still pass (130 passed, 1 skipped). I have the change ready with a unit spec and a changeset. I am not a registered collaborator, so I have not opened a pull request; I can open one if you want it. The branch: https://github.com/nodnarbnitram/workers-sdk/tree/fix-artifacts-wrapper-dispose (diff against main).
Please provide any relevant error logs
miniflare 5.20261117.0-beta:
✓ A: evicts a Durable Object that did not call Artifacts 9ms
× B: evicts a Durable Object that called Artifacts and disposed the result 10005ms
× C: evicts a Durable Object that called Artifacts 10002ms
Error: Test timed out in 10000ms.
Test Files 1 failed (1)
Tests 2 failed | 1 passed (3)
miniflare 5.20261109.0-beta with workerd 1.20261109.1:
✓ A: evicts a Durable Object that did not call Artifacts 8ms
✓ B: evicts a Durable Object that called Artifacts and disposed the result 8ms
× C: evicts a Durable Object that called Artifacts 10005ms
Test Files 1 failed (1)
Tests 1 failed | 2 passed (3)
miniflare 5.20261117.0-beta with the fixed wrapper file in place of the installed one:
✓ test/evict.spec.ts (3 tests) 19ms
Test Files 1 passed (1)
Tests 3 passed (3)
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
cloudflare/workers-sdk#17175 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days