Skip to content

fix(docs): replace hardcoded sleep() calls with polling in docsDev.test.ts#12650

Merged
fern-support merged 2 commits intomainfrom
devin/1771817553-docs-dev-polling
Feb 23, 2026
Merged

fix(docs): replace hardcoded sleep() calls with polling in docsDev.test.ts#12650
fern-support merged 2 commits intomainfrom
devin/1771817553-docs-dev-polling

Conversation

@Swimburger
Copy link
Member

@Swimburger Swimburger commented Feb 23, 2026

Description

Refs: Requested by @Swimburger
Link to Devin run

Replaces 3 hardcoded sleep() calls (20s + 40s + 40s = 100s of unconditional waiting) in docsDev.test.ts with a waitForServer() polling utility that retries the fetch request every 1 second until the server responds or a 60-second timeout is reached.

Changes Made

  • Removed the sleep() helper function
  • Added waitForServer(url, init, { interval, timeout }) which polls the endpoint, catching connection errors and retrying at a configurable interval (default: 1s interval, 60s timeout)
  • Replaced all 3 sleep() + fetch() pairs with a single waitForServer() call that returns the response as soon as the server is ready
  • Increased all three vitest test timeouts to 90s (from 30s/50s/50s) so they comfortably exceed the 60s waitForServer default

Things for reviewer to verify

  • Only connection errors trigger retries: waitForServer only 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.
  • 90s test timeouts: All three tests now use 90s vitest timeouts. Verify this is acceptable for CI run time.

Testing

  • Biome lint passes
  • ETE tests not run locally (these require a full docs dev server environment)

Open with Devin

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +21 to 23
const response = await waitForServer("http://localhost:3000/v2/registry/docs/load-with-url", {
method: "POST"
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@fern-support fern-support merged commit 9324552 into main Feb 23, 2026
74 checks passed
@fern-support fern-support deleted the devin/1771817553-docs-dev-polling branch February 23, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants