fix(core): persist resolved bindings on terminal commits#266
Open
sam-goodwin wants to merge 1 commit into
Open
fix(core): persist resolved bindings on terminal commits#266sam-goodwin wants to merge 1 commit into
sam-goodwin wants to merge 1 commit into
Conversation
After `reconcile` runs, we know each binding's fully-resolved data
payload (`bindingOutputs`) — the same payload the provider just applied
to the cloud. The `created`/`updated`/`replaced` commits were instead
persisting the raw `node.bindings`, which still contain unresolved
Output expressions for any cross-resource reference (e.g. a Hyperdrive
binding carrying `id: hyperdrive.hyperdriveId`).
JSON-serializing an Output expression silently drops the value, so the
state file stores `{ name, /* id missing */ }`. On the next plan, the
binding diff fires (`id: undefined` ↦ `id: <resolved>`) and forces a
spurious update — visible in the cloudflare-neon-drizzle example as the
Worker re-deploying on every second `alchemy deploy`.
Persist `bindingOutputs` in the terminal commits so what we store
matches what we shipped. Intermediate `creating`/`updating`/`replacing`
commits keep using raw `node.bindings` since they may run before
upstreams have published their attrs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/794b6e0@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/794b6e0@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/794b6e0 |
Contributor
Website Preview DeployedURL: https://alchemyeffectwebsite-worker-pr-266-do2grwbshjo6h7uy.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After
reconcileruns we know each binding's fully-resolved data payload (bindingOutputs) — the same payload the provider just shipped. The terminalcreated/updated/replacedcommits were instead persisting rawnode.bindings, which still hold unresolvedOutputexpressions for any cross-resource reference (e.g. a Hyperdrive binding carryingid: hyperdrive.hyperdriveId).JSON-serializing an
Outputsilently drops the value, so the state file stores{ name, /* id missing */ }. On the next plan the binding diff fires (id: undefined↦id: <resolved>) and forces a spurious update.Reproduces in
examples/cloudflare-neon-drizzle:yield* commit<CreatedResourceState>({ status: "created", ... - bindings: excludeDeletedBindings(node.bindings), + bindings: bindingOutputs, });Same change in the
updatedandreplacedterminal commits. Intermediatecreating/updating/replacingcommits keep rawnode.bindingssince they may run before upstreams have published their attrs.Regression test in
packages/alchemy/test/apply.test.tsdeploys a stack twice where one resource's binding references another's output, and asserts the second deploy noops both — and that the persisted binding payload has the peer value resolved.