Pages settings: the live block throws when the project has no active deployment
Summary
On the Pages settings page, the live block throws TypeError: Cannot read properties of null (reading 'active') when the project has no active primary deployment. The error happens on Vue 2 and on Vue 3, with both template compilers, so the Vue 3 migration did not cause it.
Cause
deployments.vuepassesnewestDeploymenttolive-block. The computed returnsnullwhen the query returns no active primary deployment.live-blockgets:is-loading="!newestDeployment && $apollo.loading". When loading ends,isLoadingbecomesfalsewhiledeploymentis stillnull.live_block.vuedeclaresdeploymentwithdefault: () => ({}). A default applies only toundefined, not tonull.- The
#titleslot then readsdeployment.active, anddomainNamereadsthis.deployment.urlwhen there is no primary domain. Both throw.
Steps to reproduce
- Open Deploy > Pages for a project with Pages that has no active primary deployment, for example after its only deployment is stopped.
- Open the browser console.
Expected: the page renders with no error.
Actual: the console shows the TypeError above, and the live block does not render its title.
A Jest spec that mounts live_block.vue with deployment: null and isLoading: false throws the same error.
Possible fixes
- Render
live-blockonly when there is a deployment (v-if="newestDeployment"). The block says "Your Pages site is live", which is not true without a deployment. - Or pass
newestDeployment || undefinedso the prop default applies, and read the fields with optional chaining.
The owning team should choose what the page shows when no deployment is active.
References
- Found during #642429. That search ruled this bug out as a compiler regression.
Edited by 🤖 GitLab Bot 🤖