test(e2e): instrument mock SSE + client stream + fix reachability probe to attribute #90 mode-B (#98)
Adds diagnostics-only instrumentation to attribute the Activation E2E positive flow's "SSE reply never renders" failure (issue #90 mode B) between (a) expo/fetch not streaming the SSE response on the Android release APK, vs (b) a mock-side broadcast bug. Does not change app behavior or fix the root cause — #90 stays open pending the next CI run's enriched logs. - tests/fixtures/mock-opencode-server.ts: per-request logging (method/path/status), per-SSE-connection connect/disconnect logging with live client count, per-broadcast event-type + client-count logging, and a 2s SSE heartbeat comment so client-side silence becomes unambiguous. - src/lib/sdk.ts global.events(): logs on the first successful reader.read() that returns data, and when the stream loop ends — proves/disproves whether expo/fetch ever delivers a byte. - scripts/run-e2e-flows.sh: the emulator->mock reachability probe used toybox wget/nc, which don't work reliably on the API-28 image. Replaced with a probe chain (curl, wget, mksh /dev/tcp, nc, then a host-side fallback) that writes a clear PASS/FAIL/UNKNOWN verdict to artifacts/diag/probe.txt without blocking the flow. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
26
tests/fixtures/mock-opencode-server.ts
vendored
26
tests/fixtures/mock-opencode-server.ts
vendored
@@ -201,6 +201,7 @@ export function createMockOpencodeServer(opts: MockServerOptions) {
|
||||
|
||||
function broadcast(type: string, properties: Record<string, unknown>) {
|
||||
const line = `data: ${JSON.stringify({ type, properties })}\n\n`
|
||||
console.log(`[mock-opencode-server] broadcast type=${type} clients=${sseClients.size}`)
|
||||
for (const res of sseClients) {
|
||||
try {
|
||||
res.write(line)
|
||||
@@ -298,6 +299,12 @@ export function createMockOpencodeServer(opts: MockServerOptions) {
|
||||
const path = url.pathname
|
||||
const method = req.method || "GET"
|
||||
|
||||
// Per-request logging: proves whether the request ever reached the mock
|
||||
// at all (attributes transport vs. app-side rendering for issue #90).
|
||||
res.on("finish", () => {
|
||||
console.log(`[mock-opencode-server] ${method} ${path} -> ${res.statusCode}`)
|
||||
})
|
||||
|
||||
if (failAuth) {
|
||||
unauthorized(res)
|
||||
return
|
||||
@@ -387,7 +394,24 @@ export function createMockOpencodeServer(opts: MockServerOptions) {
|
||||
})
|
||||
res.write(": connected\n\n")
|
||||
sseClients.add(res)
|
||||
req.on("close", () => sseClients.delete(res))
|
||||
console.log(`[mock-opencode-server] SSE connect, clients=${sseClients.size}`)
|
||||
|
||||
// Periodic heartbeat comment. If the client never sees even this, the
|
||||
// silence is a transport problem (expo/fetch not streaming), not a
|
||||
// broadcast bug — attributes issue #90 mode B.
|
||||
const heartbeat = setInterval(() => {
|
||||
try {
|
||||
res.write(": ping\n\n")
|
||||
} catch {
|
||||
clearInterval(heartbeat)
|
||||
}
|
||||
}, 2000)
|
||||
|
||||
req.on("close", () => {
|
||||
clearInterval(heartbeat)
|
||||
sseClients.delete(res)
|
||||
console.log(`[mock-opencode-server] SSE disconnect, clients=${sseClients.size}`)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user