Skip to content

fix: set PENDING status on deploy preview request and failure#7756

Merged
martinjagodic merged 1 commit intodecaporg:mainfrom
jonasbeck:fix/clear-stale-deploy-preview-state
Mar 17, 2026
Merged

fix: set PENDING status on deploy preview request and failure#7756
martinjagodic merged 1 commit intodecaporg:mainfrom
jonasbeck:fix/clear-stale-deploy-preview-state

Conversation

@jonasbeck
Copy link
Copy Markdown
Contributor

@jonasbeck jonasbeck commented Mar 16, 2026

Summary

Sets status: 'PENDING' in the deploys reducer on both DEPLOY_PREVIEW_REQUEST and DEPLOY_PREVIEW_FAILURE, preventing stale production URLs from appearing and ensuring the "Check for Preview" button remains visible during polling. Adds unit tests for the deploys reducer (none existed before).

Problem

When a user opens an existing published entry, getDeploy stores { status: "SUCCESS", url: "https://production-url/..." } in Redux. If the user then saves (creating an editorial workflow branch), getDeployPreview polls for commit statuses. Two issues:

  1. Stale production URL: If no commit status exists yet, the old SUCCESS state and production URL persisted, causing "View Preview" to link to the production URL instead of the deploy preview.
  2. Disappearing controls: Clearing status to undefined caused the deploy preview controls to disappear entirely — renderDeployPreviewControls has a guard clause if (!status) return — leaving editors with no way to manually check for a preview.

Fix

     case DEPLOY_PREVIEW_REQUEST: {
       const { collection, slug } = action.payload;
       const key = `${collection}.${slug}`;
-      state[key] = state[key] || {};
-      state[key].isFetching = true;
+      state[key] = { isFetching: true, status: 'PENDING' };
       break;
     }
     ...
     case DEPLOY_PREVIEW_FAILURE: {
       const { collection, slug } = action.payload;
-      state[`${collection}.${slug}`].isFetching = false;
+      const key = `${collection}.${slug}`;
+      state[key].isFetching = false;
+      state[key].url = undefined;
+      state[key].status = 'PENDING';
       break;
     }
  • DEPLOY_PREVIEW_REQUEST: Resets the entry to { isFetching: true, status: 'PENDING' }, clearing stale url/status while keeping the "Check for Preview" button visible.
  • DEPLOY_PREVIEW_FAILURE: Clears url and sets status: 'PENDING' so the button stays visible and clickable for manual retries.

Tests

Added packages/decap-cms-core/src/reducers/__tests__/deploys.spec.ts. Covers:

  • All three action types (REQUEST, SUCCESS, FAILURE)
  • REQUEST clears stale url and sets status to PENDING
  • FAILURE clears url and sets status to PENDING
  • selectDeployPreview selector

Fixes #7755

@jonasbeck jonasbeck requested a review from a team as a code owner March 16, 2026 15:47
Clear stale url and status in the deploys reducer on DEPLOY_PREVIEW_REQUEST
and DEPLOY_PREVIEW_FAILURE. Both cases now set status to 'PENDING' instead
of leaving it undefined, which ensures the 'Check for Preview' button
remains visible in the editor toolbar while polling is in progress or
after polling gives up.

Previously, clearing status to undefined caused the deploy preview
controls to disappear entirely (the toolbar's guard clause returns early
when status is falsy), leaving editors with no way to manually check for
a preview.

Adds unit tests for the deploys reducer (none existed before).

Fixes decaporg#7755
@jonasbeck jonasbeck changed the title fix: clear stale deploy preview state on DEPLOY_PREVIEW_FAILURE fix: set PENDING status on deploy preview request and failure Mar 16, 2026
@jonasbeck jonasbeck force-pushed the fix/clear-stale-deploy-preview-state branch 2 times, most recently from 6588ef6 to 839569b Compare March 16, 2026 19:34
Copy link
Copy Markdown
Contributor

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jonasbeck, looks solid to me

@martinjagodic martinjagodic merged commit d9e4292 into decaporg:main Mar 17, 2026
10 checks passed
@jonasbeck jonasbeck deleted the fix/clear-stale-deploy-preview-state branch March 17, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploy preview shows stale production URL after DEPLOY_PREVIEW_FAILURE

3 participants