Files
yetone e30f8ed056 devin 0.1.45: a request Devin took and then went quiet on ends in a retryable 504
wu_chong4136 on X: with the Devin plugin a session sometimes hung for
10 to 20 minutes with no reply, until the effort or the context was
changed. The plugin returns its head only with Devin's first content,
and nothing bounded the wait for Devin's head or for the next frame, so
a request Devin accepted and never answered left the agent on magpie's
keepalives with no error.

- quietFetch: Devin's head comes within QUIET (5 minutes) or the fetch
  is aborted with a Quiet error.
- quietRead: frames() waits QUIET at most between reads; on quiet the
  reader is cancelled, so the connection is let go.
- A Quiet error answers 504 "Devin sent nothing for 5 minutes; the
  request was given up so it can be sent again", stream and non-stream;
  other failures keep their 502. pingOnce uses quietFetch too.
- 5 minutes: a real probe of GetChatMessage saw the first frame 2.5s
  after the request and at most a 13s gap between frames through a
  reply, so 5 minutes of silence is not Devin thinking.

Run (mote, HOME=$(mktemp -d)):
- bun test in packages/devin: 232 pass, 0 fail (quiet.test.mjs's four
  tests among them: no head, a body that never starts, quiet after a
  frame, and frames every 50ms with QUIET at 200ms never given up).
- bun scripts/check.mjs: ok.

Broken by hand: index.mjs without quietFetch/quietRead: the three
give-up tests hang to their timeout.

Not tried: a real Devin request that goes quiet (it can't be made to);
the root suite runs on CI before publish.
2026-11-17 00:18:09 +08:00

88 lines
3.0 KiB
JavaScript

import { afterEach, expect, test } from "bun:test"
import { _internal } from "./index.mjs"
// A request Devin took and then answered nothing to held the agent for 10
// to 20 minutes with keepalives and no error (wu_chong4136 on X). Each case
// waits on the plugin's answer, not on a duration: before the quiet wait
// these held for ever and the test's own timeout failed them.
const real = globalThis.fetch
afterEach(() => {
globalThis.fetch = real
_internal.quietFor()
})
const ask = (stream) =>
_internal.complete(
{ key: "test", server: "https://devin.test", families: _internal.familiesOf(_internal.SNAPSHOT) },
{ model: "gemini-4-argon", stream, messages: [{ role: "user", content: "?" }] },
)
// a fetch that never answers, aborted only by its signal
const silentHead = (_url, init) =>
new Promise((_, reject) => init.signal.addEventListener("abort", () => reject(init.signal.reason)))
// a frame Devin sends while it thinks, with nothing an agent sees
const thinkingFrame = () => _internal.frame(new Uint8Array([0x0a, 0x01, 0x61]))
test("a request Devin never answers gives up with a 504", async () => {
_internal.quietFor(100)
globalThis.fetch = silentHead
for (const stream of [true, false]) {
const res = await ask(stream)
expect(res.status).toBe(504)
expect((await res.json()).error.message).toContain("Devin sent nothing")
}
})
test("a reply whose body never starts gives up with a 504, and is cancelled", async () => {
_internal.quietFor(100)
let cancelled = 0
globalThis.fetch = async () =>
new Response(new ReadableStream({ pull: () => new Promise(() => {}), cancel: () => void cancelled++ }))
const res = await ask(true)
expect(res.status).toBe(504)
expect((await res.json()).error.message).toContain("Devin sent nothing")
expect(cancelled).toBe(1)
})
test("a reply that goes quiet after frames that say nothing gives up with a 504", async () => {
_internal.quietFor(100)
globalThis.fetch = async () =>
new Response(
new ReadableStream({
start(c) {
c.enqueue(thinkingFrame())
},
pull: () => new Promise(() => {}),
}),
)
const res = await ask(true)
expect(res.status).toBe(504)
})
test("frames that keep coming inside the wait are never given up", async () => {
_internal.quietFor(200)
let n = 0
globalThis.fetch = async () =>
new Response(
new ReadableStream({
async pull(c) {
await new Promise((r) => setTimeout(r, 50))
if (++n < 12) return c.enqueue(thinkingFrame())
c.enqueue(_internal.frame(new Uint8Array([0x1a, 0x02, 0x68, 0x69]))) // text "hi"
const end = new TextEncoder().encode("{}")
const f = new Uint8Array(5 + end.length)
f[0] = 2
new DataView(f.buffer).setUint32(1, end.length)
f.set(end, 5)
c.enqueue(f)
c.close()
},
}),
)
const res = await ask(false)
expect(res.status).toBe(200)
expect((await res.json()).choices[0].message.content).toBe("hi")
})