Compare commits

...
2 Commits
Author SHA1 Message Date
opencode-agent[bot] 6106cb64c7 chore: generate 2026-08-17 03:35:05 +00:00
opencode-agent[bot]andAiden Cline c786ab92d3 test(cli): ignore logs before standalone readiness (#42968)
Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
2026-08-16 22:33:55 -05:00
2 changed files with 11 additions and 8 deletions
@@ -14,7 +14,7 @@ await Effect.runPromise(
const response = yield* Effect.promise(() =>
fetch(new URL("/api/health", endpoint.url), { headers: Service.headers(endpoint) }),
)
console.log(`${endpoint.pid} ${endpoint.url} ${response.status}`)
console.log(`STANDALONE_READY ${endpoint.pid} ${endpoint.url} ${response.status}`)
return yield* Effect.never
}),
),
+10 -7
View File
@@ -9,8 +9,11 @@ test("standalone server exits when its owner is killed", async () => {
stdout: "pipe",
stderr: "pipe",
})
const line = await Promise.race([readLine(owner.stdout), Bun.sleep(10_000).then(() => undefined)])
const [rawPID, url, status] = line?.split(" ") ?? []
const line = await Promise.race([
readLine(owner.stdout, "STANDALONE_READY "),
Bun.sleep(10_000).then(() => undefined),
])
const [, rawPID, url, status] = line?.split(" ") ?? []
const pid = Number(rawPID)
try {
@@ -29,7 +32,7 @@ test("standalone server exits when its owner is killed", async () => {
}
})
async function readLine(stream: ReadableStream<Uint8Array>) {
async function readLine(stream: ReadableStream<Uint8Array>, prefix: string) {
const reader = stream.getReader()
const decoder = new TextDecoder()
const chunks: string[] = []
@@ -38,14 +41,14 @@ async function readLine(stream: ReadableStream<Uint8Array>) {
if (result.done) break
chunks.push(decoder.decode(result.value, { stream: true }))
const output = chunks.join("")
const newline = output.indexOf("\n")
if (newline !== -1) {
const line = output.split("\n").find((line) => line.startsWith(prefix))
if (line) {
reader.releaseLock()
return output.slice(0, newline)
return line
}
}
reader.releaseLock()
return chunks.join("") + decoder.decode()
return (chunks.join("") + decoder.decode()).split("\n").find((line) => line.startsWith(prefix))
}
async function waitForExit(pid: number, attempts = 100): Promise<boolean> {