Skip to content

Commit 8c24465

Browse files
committed
ci: allow longer linux runtime startup
1 parent 10dfd38 commit 8c24465

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
name: Verify Linux Runtime
5353
runs-on: ubuntu-latest
5454
needs: version-consistency
55+
env:
56+
CODER_STUDIO_START_TIMEOUT_MS: 45000
5557
steps:
5658
- uses: actions/checkout@v4
5759
- name: Install Linux runtime dependencies

packages/cli/src/lib/runtime-controller.mts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ import { assertRuntimeBundle, resolvePlatformPackage } from './platform.mjs';
77
import { ensureFile, isPidRunning, openExternal, spawnBackground, spawnForeground, terminateProcess, waitForProcessExit } from './process-utils.mjs';
88
import { buildRuntimeState, clearRuntimeState, ensureStateDirs, readPackageVersion, readRuntimeState, readLogTail, writeRuntimeState } from './state.mjs';
99

10+
const DEFAULT_START_TIMEOUT_MS = 15000;
11+
12+
function resolveStartTimeout(input, env) {
13+
const candidate = input ?? env?.CODER_STUDIO_START_TIMEOUT_MS;
14+
const timeout = Number(candidate);
15+
return Number.isFinite(timeout) && timeout > 0 ? timeout : DEFAULT_START_TIMEOUT_MS;
16+
}
17+
1018
function resolveOptions(input = {}) {
1119
const stateDir = input.stateDir || resolveStateDir(input.env);
20+
const env = input.env || process.env;
1221
const host = input.host || DEFAULT_HOST;
1322
const port = Number(input.port ?? DEFAULT_PORT);
1423
const endpoint = input.endpoint || buildEndpoint(host, port);
15-
const dataDir = input.dataDir || resolveDataDir(stateDir, input.env);
24+
const dataDir = input.dataDir || resolveDataDir(stateDir, env);
1625
const logPath = input.logPath || resolveLogPath(stateDir);
1726
const tailLines = Number(input.tailLines ?? DEFAULT_LOG_TAIL_LINES);
27+
const timeoutMs = resolveStartTimeout(input.timeoutMs, env);
1828
return {
1929
...input,
2030
stateDir,
@@ -23,9 +33,10 @@ function resolveOptions(input = {}) {
2333
endpoint,
2434
dataDir,
2535
logPath,
36+
timeoutMs,
2637
tailLines: Number.isFinite(tailLines) && tailLines > 0 ? tailLines : DEFAULT_LOG_TAIL_LINES,
2738
openCommand: input.openCommand || null,
28-
env: input.env || process.env
39+
env
2940
};
3041
}
3142

@@ -192,7 +203,7 @@ export async function startRuntime(input = {}) {
192203
const errorPromise = once(child, 'error').then(([error]) => { throw error; });
193204

194205
await Promise.race([
195-
waitForReady(options.endpoint, child.pid, options.timeoutMs ?? 15000),
206+
waitForReady(options.endpoint, child.pid, options.timeoutMs),
196207
exitPromise.then(() => {
197208
throw new Error('runtime_exited_early');
198209
}),
@@ -250,7 +261,7 @@ export async function startRuntime(input = {}) {
250261

251262
try {
252263
await Promise.race([
253-
waitForReady(options.endpoint, child.pid, options.timeoutMs ?? 15000),
264+
waitForReady(options.endpoint, child.pid, options.timeoutMs),
254265
exitPromise.then(() => {
255266
throw new Error('runtime_exited_early');
256267
}),

0 commit comments

Comments
 (0)