(call: Call)
| 46 | /** The times a listener reported on stderr that its stream attached, and whether it still is: it reports each |
| 47 | * reconnect before attaching again. Changes made while no stream is attached are never delivered. */ |
| 48 | export function attachments(call: Call): { at: number[]; attached: boolean } { |
| 49 | const at: number[] = []; |
| 50 | let attached = false; |
| 51 | if (call.kind !== "gh") return { at, attached }; |
| 52 | let partial = ""; |
| 53 | for (const chunk of call.output) { |
| 54 | if (chunk.stream !== "stderr") continue; |
| 55 | const lines = (partial + chunk.text).split("\n"); |
| 56 | partial = lines.pop() ?? ""; |
| 57 | for (const line of lines) { |
| 58 | if (line.startsWith("Listening for events")) { |
| 59 | at.push(chunk.at); |
| 60 | attached = true; |
| 61 | } else if (/reconnecting|retrying|creating it again/.test(line)) { |
| 62 | attached = false; |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | return { at, attached }; |
| 67 | } |
| 68 | |
| 69 | /** When the listener's current stream attached, or undefined while no stream is attached. */ |
| 70 | export function attachedSince(call: Call): number | undefined { |
no test coverage detected