fix(docs): replace hardcoded sleep() calls with polling in docsDev.test.ts#12650
fix(docs): replace hardcoded sleep() calls with polling in docsDev.test.ts#12650fern-support merged 2 commits intomainfrom
Conversation
…st.ts Co-Authored-By: unknown <>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| const response = await waitForServer("http://localhost:3000/v2/registry/docs/load-with-url", { | ||
| method: "POST" | ||
| }); |
There was a problem hiding this comment.
🟡 waitForServer default timeout (60s) exceeds test timeout (30s) in the legacy test
The first test ("basic docs --legacy") has a vitest timeout of 30 seconds (line 37), but waitForServer uses a default timeout of 60 seconds (docsDev.test.ts:102). Since runFernCli(["check"]) also consumes some of the 30-second budget before waitForServer is even called, the test framework will always time out before waitForServer reaches its own deadline.
Root Cause and Impact
The original code used sleep(20_000) which fit within the 30-second test timeout. The new waitForServer function defaults to a 60-second timeout, which is double the test's allowed time.
If the server doesn't start quickly, the vitest timeout will fire first, producing a generic timeout error instead of the more descriptive error from waitForServer's final fetch attempt. In the worst case, the test will always fail with an unhelpful timeout message when the server takes more than ~25 seconds to start (accounting for the check step).
The other two tests have 50-second vitest timeouts, so they have the same issue but with a smaller window — if the server takes >45 seconds, vitest times out before waitForServer.
Prompt for agents
In packages/cli/ete-tests/src/tests/docs-dev/docsDev.test.ts, the first test at line 37 has a vitest timeout of 30_000ms, but waitForServer at line 21 uses the default timeout of 60_000ms. Either increase the test timeout to be larger than 60_000ms (e.g. 90_000), or pass a shorter timeout to waitForServer that fits within the test timeout. For example, change line 21-23 to pass a timeout option:
const response = await waitForServer("http://localhost:3000/v2/registry/docs/load-with-url", { method: "POST" }, { timeout: 25_000 });
Alternatively, increase the test timeout at line 37 from 30_000 to something larger like 90_000. The same consideration applies to the other two tests (lines 54-56 and 84-86) where the 60s waitForServer timeout is close to or exceeds the 50s test timeout.
Was this helpful? React with 👍 or 👎 to provide feedback.
…er 60s default Co-Authored-By: unknown <>
Description
Refs: Requested by @Swimburger
Link to Devin run
Replaces 3 hardcoded
sleep()calls (20s + 40s + 40s = 100s of unconditional waiting) indocsDev.test.tswith awaitForServer()polling utility that retries the fetch request every 1 second until the server responds or a 60-second timeout is reached.Changes Made
sleep()helper functionwaitForServer(url, init, { interval, timeout })which polls the endpoint, catching connection errors and retrying at a configurable interval (default: 1s interval, 60s timeout)sleep()+fetch()pairs with a singlewaitForServer()call that returns the response as soon as the server is readywaitForServerdefaultThings for reviewer to verify
waitForServeronly retries on thrown exceptions (e.g.ECONNREFUSED). A server that starts but returns an error HTTP status will not be retried — the response is returned as-is for the test assertions to validate. Confirm this is the desired behavior.Testing