Skip to content

Wrangler keepNames breaks serialized native storage read and restore realms #776

Description

@kamilio

Confirmed exact production-provider failure

With public @poe-platform/safe-bash@0.1.690 bundled by normal Wrangler defaults, native Cloudflare navigation to https://example.com succeeds, then the automatic owned storage checkpoint fails:

Native storage origin operation failed: ReferenceError: __name is not defined
    at collectStorageOrigin (<anonymous>:8:35)

Exact evidence: /tmp/poe2-playwright-690-cloud-storage.log, deployed worker 44465a2d.

The package serializes collectStorageOrigin.toString() and restoreOrigin.toString() into an isolated browser realm. Wrangler's default keepNames transform inserts references to a bundle-scoped __name helper into nested functions. The serialized function body does not carry that outer helper into the browser realm. The native fixture's keepNames: false build did not exercise production bundling.

Required behavior

Both read and restore expressions must be self-contained after supported consumer bundling, including keepNames: true and minification. Use maintained generated literal realm sources, preserving the typed canonical implementation and verifying generation stays synchronized. Do not require a consumer-specific bundler flag or private API workaround. Add a genuine compiler-differential regression that bundles with naming helpers and executes both expressions in a fresh realm, then verify the public release and real Cloudflare worker.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions