Skip to content

cf dev silently ignores --persist-to #22

Closed

Description

@7kaji

cf dev --persist-to <dir> exits normally but ignores the flag, so the dev server keeps using its default state directory. With two Workers sharing one local D1/R2 through --persist-to, this shows up as no such table errors instead of a clear message.

Cause

The global middleware already rejects --persist-to without --local, and --local on cf dev. But it reads argv.persistTo, and cf dev disables camel-case-expansion, so only argv["persist-to"] exists there and the checks never run.

Forwarding the flag isn't an option: the delegates accept only --mode, --port, --host and --local (cloudflare/workers-sdk#14184), and node bin/cf-wrangler.js dev --persist-to x exits with Unknown option '--persist-to'.

Suggested fix

Read the kebab-case key in the middleware and fail with --persist-to is not supported by cf dev., matching the existing --local check (--help still allowed). A patch with tests and a changeset is here (pnpm check passes):
7kaji@3703629

I couldn't open a PR because this repository only accepts pull requests from collaborators.

Related (possible follow-ups)

  • Supporting --persist-to in cf dev would first need the delegate contract extended in workers-sdk.
  • cf dev -- --port 8787 drops everything after --.
  • cf's --local commands default to ~/.config/cloudflare/state, while wrangler dev defaults to .wrangler/state, so cf d1 migrations apply --local and cf dev see different local state.

Version: cf 1.0.0-beta.5 (the code is unchanged on main at bf0a0e7), wrangler 4.142.0 / 4.143.0, macOS.

Activity

  1. added theissue type on Sep 29, 2026
  2. 0xkohe commented on Oct 3, 2026

    @0xkohe

    Confirmed the -- forwarding issue on cf 1.0.0-beta.12 (Linux, Node.js 26.10.0). Using an argv-printing delegate:

    Command Delegate receives
    cf dev --port 8787 ["dev", "--port", "8787"]
    cf dev -- --port 8787 ["dev"]
    cf dev -- --local ["dev"]

    Arguments after -- are silently dropped.

    Is forwarding after -- intended to be supported? Separately, since cf dev --local is explicitly rejected, what is the supported way to request Wrangler’s local-only startup through cf?

    Happy to open a separate issue for the forwarding case if preferred.

  3. lnv-louis commented on Oct 3, 2026

    @lnv-louis

    I second this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions