Skip to content

Commit 6693cfc

Browse files
committed
fix(platform): move the zone's startup refusal behind the data seam
check:platform-design holds @sim/logger to lib/data, and the zone's proxy imports mode.ts, so it gets its own module.
1 parent e0dfcb2 commit 6693cfc

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

‎apps/sim/platform/docs/org-parity.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,4 @@ The shell lane's rows, one per row of its audit. `shell.spec` is `checks/live/sh
379379
| Per-organization rollout: `platform-org-ui` reaches a targeted organization by id and no other, on the same deployment, through the real AppConfig client against a fixture of its service | `lib/platform/rollout.ts`, `lib/core/config/feature-flags.ts` | Done | "a targeted organization is handed to the Platform", "an organization outside the rollout stays on /o". No real AppConfig deployment has been read. Each route bundle polls on its own clock, so a change can reach the surface API and `/o` up to a poll apart, and until then `/o` can hand off to a zone that answers 404 |
380380
| A rollback under an open tab: a client navigation keeps working, because the rollout gate lives in a layout that does not re-render, and a reload's 404 offers a way off the zone | `live-shell.tsx`, `lib/data/landing.ts` | Done | "a rollback under an open tab"; `landing.test.ts` for the root's decision. The 404's home button used to loop back to it |
381381
| Self-hosted, no zone, no flag: boots, `/o` is served by the main app, `/org` is absent | `next.config.ts`, `lib/platform/rollout.ts` | Done | "a self-hosted deployment with no zone boots", "a self-hosted organization is served by the main app", "a self-hosted deployment has no /org", in the `live (flag-off)` job |
382-
| A production zone behind a base path with no API origin, or on fixtures, refuses to start | `instrumentation.ts`, `lib/data/mode.ts` | Done | "a production zone with no API origin refuses to start", "a production zone on fixtures refuses to start", "a production zone with an API origin starts", each a real `next start` of the build. `instrumentation.ts` exits, because Next only logs a failed `register()` and answers 500 |
382+
| A production zone behind a base path with no API origin, or on fixtures, refuses to start | `instrumentation.ts`, `lib/data/mode.ts` | Done | "a production zone with no API origin refuses to start", "a production zone on fixtures refuses to start", "a production zone with an API origin starts", each a real `next start` of the build. `lib/data/startup.ts` exits, because Next only logs a failed `register()` and answers 500 |
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
/**
2-
* Runs when the server starts, so a misconfigured zone never takes a request. Throwing is not enough:
3-
* Next logs a failed `register()` and keeps the process up answering 500, which a supervisor reads as
4-
* running. Only exiting fails the deployment.
5-
*/
1+
/** Runs when the server starts, so a misconfigured zone never takes a request. */
62
export async function register() {
73
if (process.env.NEXT_RUNTIME !== 'nodejs') return
8-
const { assertDeployableMode } = await import('@/platform/lib/data/mode')
9-
try {
10-
assertDeployableMode()
11-
} catch (error) {
12-
const [{ createLogger }, { getErrorMessage }] = await Promise.all([
13-
import('@sim/logger'),
14-
import('@sim/utils/errors'),
15-
])
16-
createLogger('PlatformZone').error('Refusing to start', { error: getErrorMessage(error) })
17-
process.exit(1)
18-
}
4+
const { exitUnlessDeployable } = await import('@/platform/lib/data/startup')
5+
exitUnlessDeployable()
196
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'server-only'
2+
import { createLogger } from '@sim/logger'
3+
import { getErrorMessage } from '@sim/utils/errors'
4+
import { assertDeployableMode } from '@/platform/lib/data/mode'
5+
6+
const logger = createLogger('PlatformZone')
7+
8+
/**
9+
* Stops a misconfigured production zone. Throwing is not enough: Next logs a failed `register()` and
10+
* keeps the process up answering 500, which a supervisor reads as running. Only exiting fails the
11+
* deployment. Apart from `mode`, because the zone's proxy imports that and has no use for this.
12+
*/
13+
export function exitUnlessDeployable() {
14+
try {
15+
assertDeployableMode()
16+
} catch (error) {
17+
logger.error('Refusing to start', { error: getErrorMessage(error) })
18+
process.exit(1)
19+
}
20+
}

0 commit comments

Comments
 (0)