Split out of #1217 at review: it touches the request path of every proxied app, so it gets its own pull and its own review.
The sleep sweep counts a proxied request only from the first byte of its answer. So an answer slower than the idle window can have its app stopped while the request is still waiting on it. On a loaded check machine, that is what turns test/apps-busy.test.ts "an open stream keeps the app awake until it closes" red: the app is put to sleep while the stream's headers are still on their way.
The fix: the proxy holds the environment from the moment it passes a request until its answer begins (busy reason request, inside the same grace). That is commit 7a4ba31 (src/apps/busy.ts, proxy.ts, runtime.ts, test/apps-busy.test.ts), which was reverted from #1217 in cfaa621. Pick it up from there.
Done looks like: a request whose answer takes longer than the idle window keeps its app running, and a test fails without the change.
Split out of #1217 at review: it touches the request path of every proxied app, so it gets its own pull and its own review.
The sleep sweep counts a proxied request only from the first byte of its answer. So an answer slower than the idle window can have its app stopped while the request is still waiting on it. On a loaded check machine, that is what turns
test/apps-busy.test.ts"an open stream keeps the app awake until it closes" red: the app is put to sleep while the stream's headers are still on their way.The fix: the proxy holds the environment from the moment it passes a request until its answer begins (busy reason
request, inside the same grace). That is commit 7a4ba31 (src/apps/busy.ts, proxy.ts, runtime.ts, test/apps-busy.test.ts), which was reverted from #1217 in cfaa621. Pick it up from there.Done looks like: a request whose answer takes longer than the idle window keeps its app running, and a test fails without the change.