mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Add local publish timeout for spacetime command in spacetime-publish.mjs
- Introduced a timeout for the local publish process to prevent hanging operations. - Added error handling for timeout scenarios, providing user feedback if the command exceeds the specified duration.
This commit is contained in:
parent
31d56d1c0f
commit
56c1331c20
@ -43,6 +43,7 @@ if (target === "prod" && !process.env.HEXCLAVE_SPACETIMEDB_ALLOWED_ISSUERS && !p
|
||||
console.error("Error: HEXCLAVE_SPACETIMEDB_TOKEN_ISSUER (or HEXCLAVE_SPACETIMEDB_ALLOWED_ISSUERS) must be set for prod publish — the deployed internal tool's public URL, which serves the OIDC discovery document SpacetimeDB validates tokens against.");
|
||||
process.exit(1);
|
||||
}
|
||||
const LOCAL_PUBLISH_TIMEOUT_MS = 60_000;
|
||||
|
||||
let exitCode = 1;
|
||||
try {
|
||||
@ -50,7 +51,14 @@ try {
|
||||
if (inject.status !== 0) {
|
||||
exitCode = inject.status ?? 1;
|
||||
} else {
|
||||
const publish = spawnSync("spacetime", args, { stdio: "inherit" });
|
||||
const publish = spawnSync("spacetime", args, {
|
||||
stdio: "inherit",
|
||||
...(target === "local" ? { timeout: LOCAL_PUBLISH_TIMEOUT_MS } : {}),
|
||||
});
|
||||
if (publish.error?.code === "ETIMEDOUT") {
|
||||
console.error(`[spacetime-publish] 'spacetime publish' did not finish within ${LOCAL_PUBLISH_TIMEOUT_MS / 1000}s and was killed. The SpacetimeDB container may be unresponsive — try 'pnpm restart-deps'.`);
|
||||
}
|
||||
// On timeout (or any kill-by-signal) status is null, which maps to 1 here.
|
||||
exitCode = publish.status ?? 1;
|
||||
}
|
||||
} finally {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user