Skip to content

Commit d429867

Browse files
committed
ci: use packaged dist/index.js for host e2e instead of raw TS source
Smoke workflow `smoke-opencode-linux.yml` (just added) proved that opencode-on-Linux is healthy in isolation: both curl and bun's fetch reach /doc in seconds with either 127.0.0.1 or 0.0.0.0 binding. So the host e2e hang is NOT a Linux opencode bug. The remaining structural difference between smoke (~10s spawn-to-OK) and host e2e (~5min timeout) is plugin loading. Host e2e was pointing opencode at `packages/plugin/src/index.ts` — raw TypeScript source spanning hundreds of submodule imports. Bun's runtime TS transpile + dynamic resolution can be slow on cold Linux runners. Production never loads from src/ — published users get a single bundled `dist/index.js`. Testing src/ exposes us to a slowness path real users never see. CI workflows already build dist before host e2e, so the file is available; the harness just wasn't using it. Resolution: prefer `packages/plugin/dist/index.js` when it exists, fall back to `src/` only when running locally without a build (which also avoids breaking local devs who haven't built).
1 parent 444845b commit d429867

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • packages/e2e-tests/src/opencode-runner

packages/e2e-tests/src/opencode-runner/spawn.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@
88
*/
99

1010
import { type ChildProcess, spawn } from "node:child_process";
11-
import { mkdirSync, writeFileSync } from "node:fs";
11+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
1212
import { tmpdir } from "node:os";
1313
import { join, resolve } from "node:path";
1414

1515
const REPO_ROOT = resolve(import.meta.dir, "../../../..");
16-
const PLUGIN_ENTRY = join(REPO_ROOT, "packages/plugin/src/index.ts");
16+
// Prefer the bundled `dist/index.js` (what published users actually run)
17+
// over raw `src/index.ts`. The bundled file is one ~5MB file with all imports
18+
// inlined; loading it is fast even on cold runners. The TS-source path
19+
// triggers Bun's runtime TS transpile + dynamic resolution across hundreds
20+
// of submodule imports — on slow Linux CI runners this can take long enough
21+
// to make `opencode serve` appear hung when it's just blocked in plugin
22+
// load. Production never loads from src/, so testing src/ doesn't reflect
23+
// reality and exposes us to a slowness path users never see.
24+
const PLUGIN_DIST_ENTRY = join(REPO_ROOT, "packages/plugin/dist/index.js");
25+
const PLUGIN_SRC_ENTRY = join(REPO_ROOT, "packages/plugin/src/index.ts");
26+
const PLUGIN_ENTRY = existsSync(PLUGIN_DIST_ENTRY) ? PLUGIN_DIST_ENTRY : PLUGIN_SRC_ENTRY;
1727

1828
export interface IsolatedEnv {
1929
configDir: string;

0 commit comments

Comments
 (0)