Skip to content

Cloudflare Worker with directory assets never converges to a no-op plan #1047

Description

@magoz

Version

alchemy@2.0.0-beta.66

The same behavior appears to be present on main.

What happened?

A Cloudflare Worker using directory assets without a caller-supplied hash always appears as changed in alchemy plan, even when the directory contents are unchanged.

For example:

yield* Cloudflare.Worker("Worker", {
  main: "./src/worker.ts",
  assets: {
    directory: "./dist",
  },
});

After deploying once, running alchemy plan again reports a Worker update.

readAssets calculates and stores a deterministic asset hash while applying the update, but the Worker diff returns changed when assets.hash is absent:

Expected behavior

When the Worker bundle, configuration, and asset directory contents are unchanged, alchemy plan should report a no-op without requiring the caller to implement separate directory hashing.

Current workaround

Supplying a deterministic assets.hash makes successive plans converge, but this requires duplicating asset hashing in application code.

Context

I encountered this while adding an Alchemy deployment path for Executor’s Cloudflare host. The host builds dist before each plan; even when two builds produce identical contents, the Worker still plans an update unless we supply assets.hash.

The current workaround computes a content hash for dist and passes it to the Worker:

UsefulSoftwareCo/executor#1510 (comment)

The review discussion concluded that Alchemy should ideally handle this and suggested opening this issue.

Metadata

Metadata

Assignees

No one assigned

    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