Repository navigation
Fix: set project-wide integration hookTimeout/testTimeout in vitest.config.ts - #548
Merged
AmaadMartin merged 1 commit intoJul 31, 2026
Conversation
Install-heavy `beforeAll` hooks in the `integration` Vitest project run `npm install` (and sometimes `npm run build`) per fixture, which exceeds Vitest's 10s default hookTimeout on a slow or loaded machine and flakes with `Hook timed out in 10000ms`. Only 6 of the 35 integration test files declare their own timeout constant, so the rest had no protection. Give the `integration` project block two named budgets: INTEGRATION_HOOK_TIMEOUT_MS = 120000 INTEGRATION_TEST_TIMEOUT_MS = 60000 The values differ because the evidence does. The hook budget covers `npm install` + `npm run build` across six fixtures; the test budget matches the largest per-file timeout in the repo, so a genuinely hung test is not given more rope than anything has ever needed -- which matters because validation.yaml sets no timeout-minutes and run-tests is a 3-way OS matrix. Scoped to the `integration` project so unit/e2e/cross-language keep Vitest's fast defaults. Per-file `it()`/hook timeouts still override both.
AmaadMartin
force-pushed
the
fix/integration-project-hook-timeout
branch
from
July 29, 2026 02:45
f5f13c4 to
ad54523
Compare
This was referenced Jul 29, 2026
Fix: set project-wide integration hookTimeout/testTimeout in vitest.config.ts
AmaadMartin/adk-js#118
Closed
Open
kalenkevich
approved these changes
Jul 31, 2026
Merged
This was referenced Jul 31, 2026
Open
kalenkevich
pushed a commit
that referenced
this pull request
Sep 14, 2026
…625) * fix(cli): surface model errors and make agent stack traces readable `adk run` with a bad, expired, or wrong API key -- the most common first-run failure -- printed nothing at all and exited 0: $ npx adk run agent.ts [user]: INFO: [ADK] Sending out request, model: gemini-flash-latest... [user]: EXITCODE=0 Three separate defects: 1. Model failures ride on `Event.errorCode` / `Event.errorMessage` with no `content` (llm_agent.ts), but both event loops in cli_run.ts only printed `event.content.parts`, so the error was dropped. Print it to stderr and set a non-zero exit code, in interactive and replay mode. 2. `runAgent`'s catch was `console.log(e)` -> stdout, exit 0. Now `console.error` plus `process.exitCode = 1` (same for the run subcommand and the CLI entrypoint). 3. The agent loader esbuild-bundled and minified the user's file, so every trace pointed into a mangled, already-deleted temp bundle: `at new H_ (/tmp/adk_agent_loader/.../agent.cjs:537:1742)`. Minification is now opt-in and used only for `adk deploy`; local commands emit an inline source map, so traces name the developer's own file and line. * fix(dev): make the debug build opt-in and share one agent preload pass The unminified, source-mapped bundle is what makes an agent's stack trace readable, but it is 3.5x larger (23.6 MB -> 83.1 MB over the four agents in the app_loader fixture) and it was applied to every caller, including ones that never read a trace. That pushed `app_loader_test.ts`'s discovery test from 18.3s to 29.6s locally against a 40s budget, and made macos-latest fail deterministically. Every CLI entry point already passes `minify` explicitly - run/web/api_server ask for the debug build, both deploy targets opt out - so the loader-level default is reached only by programmatic callers. Restore it to the historical "minify when bundling", and gate the source map (and the plugin's chained entry map) on an explicit `minify: false`. `adk run` still prints `at new WeatherClient (/path/boom_agent.ts:6:13)` on stderr with exit 1; nobody else pays for it. Two pre-existing problems in the same area, which is why this test also failed on unrelated PRs such as the docs-only #623: - `preloadAgents()` only set its "done" flag after the whole pass finished, so overlapping callers each re-bundled every agent - 4 esbuild builds became 12 and 5.1s became 13.6s. One timing-out test therefore made the next two slower, which is why the failures arrived in clusters. `adk web` hits the same path from several routes on concurrent requests. - `app_loader_test.ts` pinned tests *and hooks* to 40s, overriding the 60s/120s budgets vitest.config.ts sets for the integration project in #548. A cold `npm install` (~60s) blew the hook budget, and 40s never suited the discovery test: it takes 29.8s on a *green* macos-latest run of main. * refactor(cli): carry minify inside the agent file options object getAgentFileOptions took minify as a trailing positional parameter, so the two deploy call sites had to spell out what the bare `true` meant with a `/* minify= */` marker comment. Making it a field of the options object the function already takes lets the call site name it directly. --------- Co-authored-by: Amaad Martin <[email protected]>
AmaadMartin
pushed a commit
to AmaadMartin/adk-js
that referenced
this pull request
Oct 8, 2026
… vitest projects The unit projects inherited Vitest's 5s default, which has been observed to expire on a loaded runner: dev/test/utils/agent_loader_test.ts's ".ts agent file" case does real filesystem work (mkdir, symlink, dynamic import of a written CJS module) and measures ~0.8s quiet but 6.8-7.9s under CPU starvation. Sizes the budget at 30s from measurement - 29x the slowest legitimate unit test (~1.0s) and 3.3x the worst reproduced degraded run - mirroring the integration project's constants added in google#548. A project entry does not inherit the root test timeout, so it has to be declared per project. No hookTimeout is added: no unit hook approached its budget at any starvation level.
6 of 9 tasks
AmaadMartin
pushed a commit
that referenced
this pull request
Oct 9, 2026
… vitest projects (#1010) * fix(test): set an explicit testTimeout for the unit:core and unit:dev vitest projects The unit projects inherited Vitest's 5s default, which has been observed to expire on a loaded runner: dev/test/utils/agent_loader_test.ts's ".ts agent file" case does real filesystem work (mkdir, symlink, dynamic import of a written CJS module) and measures ~0.8s quiet but 6.8-7.9s under CPU starvation. Sizes the budget at 30s from measurement - 29x the slowest legitimate unit test (~1.0s) and 3.3x the worst reproduced degraded run - mirroring the integration project's constants added in #548. A project entry does not inherit the root test timeout, so it has to be declared per project. No hookTimeout is added: no unit hook approached its budget at any starvation level. * fix(test): trim the UNIT_TEST_TIMEOUT_MS doc comment to the non-obvious facts The comment restated the per-file override note already carried by INTEGRATION_TEST_TIMEOUT_MS four lines below, and the sizing measurements belong in the commit message and PR description rather than in the config. Keeps only why the 5s default expires and why the budget is declared per project, matching the length of the two neighbouring budget constants.
9 tasks done
prasanna8585
pushed a commit
to prasanna8585/adk-js
that referenced
this pull request
Nov 10, 2026
…oogle#625) * fix(cli): surface model errors and make agent stack traces readable `adk run` with a bad, expired, or wrong API key -- the most common first-run failure -- printed nothing at all and exited 0: $ npx adk run agent.ts [user]: INFO: [ADK] Sending out request, model: gemini-flash-latest... [user]: EXITCODE=0 Three separate defects: 1. Model failures ride on `Event.errorCode` / `Event.errorMessage` with no `content` (llm_agent.ts), but both event loops in cli_run.ts only printed `event.content.parts`, so the error was dropped. Print it to stderr and set a non-zero exit code, in interactive and replay mode. 2. `runAgent`'s catch was `console.log(e)` -> stdout, exit 0. Now `console.error` plus `process.exitCode = 1` (same for the run subcommand and the CLI entrypoint). 3. The agent loader esbuild-bundled and minified the user's file, so every trace pointed into a mangled, already-deleted temp bundle: `at new H_ (/tmp/adk_agent_loader/.../agent.cjs:537:1742)`. Minification is now opt-in and used only for `adk deploy`; local commands emit an inline source map, so traces name the developer's own file and line. * fix(dev): make the debug build opt-in and share one agent preload pass The unminified, source-mapped bundle is what makes an agent's stack trace readable, but it is 3.5x larger (23.6 MB -> 83.1 MB over the four agents in the app_loader fixture) and it was applied to every caller, including ones that never read a trace. That pushed `app_loader_test.ts`'s discovery test from 18.3s to 29.6s locally against a 40s budget, and made macos-latest fail deterministically. Every CLI entry point already passes `minify` explicitly - run/web/api_server ask for the debug build, both deploy targets opt out - so the loader-level default is reached only by programmatic callers. Restore it to the historical "minify when bundling", and gate the source map (and the plugin's chained entry map) on an explicit `minify: false`. `adk run` still prints `at new WeatherClient (/path/boom_agent.ts:6:13)` on stderr with exit 1; nobody else pays for it. Two pre-existing problems in the same area, which is why this test also failed on unrelated PRs such as the docs-only google#623: - `preloadAgents()` only set its "done" flag after the whole pass finished, so overlapping callers each re-bundled every agent - 4 esbuild builds became 12 and 5.1s became 13.6s. One timing-out test therefore made the next two slower, which is why the failures arrived in clusters. `adk web` hits the same path from several routes on concurrent requests. - `app_loader_test.ts` pinned tests *and hooks* to 40s, overriding the 60s/120s budgets vitest.config.ts sets for the integration project in google#548. A cold `npm install` (~60s) blew the hook budget, and 40s never suited the discovery test: it takes 29.8s on a *green* macos-latest run of main. * refactor(cli): carry minify inside the agent file options object getAgentFileOptions took minify as a trailing positional parameter, so the two deploy call sites had to spell out what the bare `true` meant with a `/* minify= */` marker comment. Making it a field of the options object the function already takes lets the call site name it directly. --------- Co-authored-by: Amaad Martin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
The
integrationproject block invitest.config.tsset notestTimeoutorhookTimeout, so every hook and test in that project inherited Vitest's defaults(
hookTimeout: 10000ms,testTimeout: 5000ms). Many integration tests areinstall-heavy — their
beforeAllrunsnpm install(and sometimesnpm run build) inside a fixture project, which routinely exceeds 10s on acold/loaded machine and flakes with
Error: Hook timed out in 10000ms.Individual files worked around this by inventing per-file timeout constants with
inconsistent values (
20000/40000/60000), and the most exposed hook —the
beforeAllintests/integration/build_setup/build_setup_test.ts, whichdoes both
npm installandnpm run build— passed no explicit timeout at alland relied on the flaky 10s default.
Solution:
Add a named constant
INTEGRATION_TIMEOUT_MS = 120000and apply it as bothhookTimeoutandtestTimeouton theintegrationVitest project block only.hookTimeoutfixes the concretenpm install/npm run buildhook flake.testTimeoutgives a matching safe default to the test bodies. Explicitper-
it()/ per-hook timeouts still override it, so nothing regresses.120000sits comfortably above every existing per-file value(
20000/40000/60000) and above the a2a server timeouts (60000).The change is deliberately scoped to the
integrationproject rather than thetop-level
testblock, so the fastunit:*projects keep quick failuredetection. It touches no test files. Per the repo style guideline ("Use named
constants for fixed values instead of hardcoding numbers"), the value is a
documented named constant rather than an inline literal.
Notes for reviewers:
the coverage
includeglobs (core/src,dev/src,integrations/src) istouched, so there are no new instrumented production lines to cover.
TEST_EXECUTION_TIMEOUTconstants is queued separately and must land afterthis change; the targeted
build_setup_test.tsflake fix ships separately.This PR edits only
vitest.config.tsto avoid coupling a shared-config changewith those and to avoid merge conflicts.
Testing Plan
Unit Tests:
No unit test is added: the change is a static config literal in
vitest.config.ts, which is not part of the coverage-instrumented source set. Abespoke test asserting on the raw config object would test Vitest's own config
plumbing, not ADK behavior, and is out of scope. As a regression guard, a
targeted unit run
(
vitest run --project unit:core core/test/skills/skill_test.ts) passed withunchanged fast-timeout behavior, confirming the
unit:*projects areunaffected.
Manual End-to-End (E2E) Tests:
Before/after proof that the new
hookTimeoutis actually in effect, run with nomocks:
tests/integration/whosebeforeAllsleeps 11s(longer than the old 10s default) with no explicit per-hook timeout, then
a trivial
it(...).npx vitest run --project integration <scratch_test>— passes at ~11swith this change; fails with
Error: Hook timed out in 10000ms.when thechange is reverted. (Verified both directions locally; the scratch test was
not committed.)
npx vitest run --project integration tests/integration/build_setup/build_setup_test.ts— passes (20 passed, 4 skipped). This exercises the exact bare
beforeAll(
npm installplusnpm run buildper fixture) that was most exposed to the10s flake.
Tooling gates on the changed file:
prettier --check vitest.config.ts(clean)and
eslint vitest.config.ts(clean) both pass;tsc --noEmitreports zeroerrors on
vitest.config.ts(the change adds no new type errors).Checklist
Additional context
This PR is config-only: the entire diff is 11 added lines in
vitest.config.ts(a documented
INTEGRATION_TIMEOUT_MSconstant plus the two fields on theintegrationproject block).