Repository navigation
Description
Summary
Summary of the issue
cf r2 buckets list --local succeeds with an empty bucket list after a Worker writes to a configured local R2 bucket through cf dev. The running dev server's Local Explorer lists that bucket, and the CLI can read the stored object when given the bucket name.
Steps to reproduce
Reproduction (optional)
- In an empty directory, initialize the package and install the three dependencies. The Worker and its R2 binding run locally and do not require Cloudflare credentials.
npm init -y
npm pkg set type=module
npm install --save-dev [email protected] @cloudflare/[email protected] [email protected]- Save
setup-fixture.shfrom the block below and runsh setup-fixture.shin the project directory. It writes a Vite config with remote bindings disabled, a Worker config with one R2 binding, and the Worker source. It exits after writing the three files.
Reproduction script: setup-fixture.sh
cat > cloudflare.config.ts <<'CONFIG'
import { bindings, defineConfig } from 'cf/config';
export default defineConfig({
worker: {
name: 'bucket-list-repro',
compatibilityDate: '2026-01-01',
entrypoint: './index.ts',
env: { R2: bindings.r2({ name: 'local-bucket' }) },
},
});
CONFIG
cat > vite.config.ts <<'CONFIG'
import { cloudflare } from '@cloudflare/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({ plugins: [cloudflare({ remoteBindings: false })] });
CONFIG
cat > index.ts <<'WORKER'
export default {
async fetch(request, { R2 }) {
if (request.method === 'POST') await R2.put('probe', 'sample');
return new Response('ready');
},
};
WORKER- Start
npx cf dev --host 127.0.0.1 --port 8788 --strictPortin that directory. From a second shell in the same directory, seed the bucket, compare the two lists, and read the object by its explicit bucket name.
curl -fsS -X POST http://127.0.0.1:8788/
curl -fsS http://127.0.0.1:8788/cdn-cgi/local/explorer/api/r2/buckets
npx cf r2 buckets list --local
npx cf r2 buckets list --local --persist-to .cloudflare/state
npx cf r2 objects get probe --bucket-name local-bucket --local- Stop
cf devand repeat the bucket list and object read using the same project directory.
Expected behavior
Expected behaviour
The local bucket list includes local-bucket, whose existence is visible through the dev server's Local Explorer and whose object is readable using the same CLI and state. The Cloudflare CLI project guide lists cf r2 buckets list among supported local commands and describes local commands as using persisted state shared with Vite development.
Actual behavior
Relevant error logs (optional)
The Local Explorer request returns HTTP 200 with result.buckets equal to [{"name":"local-bucket"}]. Both CLI listings exit 0 with the following result. The CLI object read exits 0 and prints sample. After dev stops, the listing remains empty while the object read still succeeds.
stdout: {"buckets": []}
stderr: result_info: {"count":0,"total_count":0}
Evidence
- Expected source: Cloudflare CLI project guide, Local resource data, which lists local bucket listing and explains the shared project state directory.
- Failure source: The isolated Worker fixture and observed
cfstdout, stderr, exit status, and Local Explorer response above. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
The CLI's local runtime setup starts a separate Miniflare session with shared persistence and an inert worker. The object-read control confirms that the session reaches the project's stored data. The results leave open how the CLI should obtain the bucket inventory.
Restoration check
With the same Worker and seeded object, assert that cf r2 buckets list --local includes local-bucket for both implicit and explicit project state, and that object reads still return sample. Keep the persisted-state assertion after cf dev exits to exercise the documented standalone mode.
Runtime or environment
Version of cf used
1.0.0-rc.1 from npm and the package built from the default-branch revision shown in the local runtime link. Both reported the same version and reproduced the behavior.
System information and package versions
macOS 27.2 arm64, Node 26.13.1, npm 12.2.2, @cloudflare/vite-plugin 2.0.0-rc.1, Vite 8.3.8, and CLI-bundled Miniflare 5.20261117.0-beta.
References
--localcommands read a different state directory thancf dev, and local list commands return[]#224 — the earlier discovery report covers D1 and KV lists and predates the project-state path change.- fix: store --local state in the project's .cloudflare/state directory #525 — this aligned the local state path with Vite. The object-read control above confirms that alignment in this fixture.
- List commands return inconsistent JSON shapes (
r2 buckets listandimages listwrap the array) #346 — this concerns the JSON wrapper shape. This report concerns the bucket omitted from the wrapper.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: Scripts and developers using the advertised local discovery command get an empty success even when the bucket contains accessible data.
- Workaround status: available
- Workaround basis: The running dev server's Local Explorer lists the bucket, and command-line object operations work when given a name from that inventory or the project config.
Activity