Latest branch deploy url always pointing to the old permalink from a stale deploy

npx netlify-cli deploy \
  --dir=build \
  --functions=src/functions/build \
  --site="$NETLIFY_PROD_SITE_ID" \
  --alias="canary" \
  --message="Branch deploy: canary@<commit-sha>"
  • We use the above command on our CI/CD runners to deploy our canary branch.

  • This creates a branch deploy (not a production deploy) on the production Netlify site (xyz.netlify.app), accessible at the alias URL canary--xyz.netlify.app. The edge function in split-test.ts is what routes traffic to this branch deploy based on the cookie.

  • Our master branch is set as Production deploy

  • We have custom logic to route our users to the canary branch deploy when they visit our production site

  • Whenever a new deploy is published to the canary alias, the actual endpoint canary--xyz.netlify.app still points to the permalink from the previous deployid in netlify and we have to manually delete the old deployment for the url to point to the latest permalink

    For context:
    We were previously using the split test functionality to enable canary testing between the master and the canary branches

CLI does not create a branch deploy. A branch deploy needs a branch. CLI uses API deploys. The alias flag gives an illusion of a branch deploy for predictable URLs, but it does not create a branch. So if you use the alias with the same name as a previously deployed branch, we’d continue serving the real branch.

Thank you for the quick response @hrishikesh


Can I delete the old branch deploy for canary in Netlify’s dashboard (Deploys → filter by branch → delete the stale canary
branch deploy)? This should free up the subdomain for the canary alias deploys, right?

I had deleted the last branch deploy of the canary branch that was successfully deployed via build and deploy in Netlify, but we are still facing an issue
where a new CLI deploy of the canary alias never updates the URL to point to the latest deploy automatically, as branch deploys did within Netlify.

I have already turned off branch deploys.


Ibbyyt tr é r r r é rvr r r