Skip to content

Fix: set project-wide integration hookTimeout/testTimeout in vitest.config.ts - #548

Merged
AmaadMartin merged 1 commit into
google:mainfrom
AmaadMartin:fix/integration-project-hook-timeout
Jul 31, 2026
Merged

AmaadMartin merged 1 commit into
google:mainfrom
AmaadMartin:fix/integration-project-hook-timeout

Conversation

@AmaadMartin

Copy link
Copy Markdown
Collaborator

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):

  • N/A — no existing issue; the change is described below.

2. Or, if no issue exists, describe the change:

Problem:

The integration project block in vitest.config.ts set no testTimeout or
hookTimeout, so every hook and test in that project inherited Vitest's defaults
(hookTimeout: 10000 ms, testTimeout: 5000 ms). Many integration tests are
install-heavy — their beforeAll runs npm install (and sometimes
npm run build) inside a fixture project, which routinely exceeds 10s on a
cold/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 beforeAll in tests/integration/build_setup/build_setup_test.ts, which
does both npm install and npm run build — passed no explicit timeout at all
and relied on the flaky 10s default.

Solution:

Add a named constant INTEGRATION_TIMEOUT_MS = 120000 and apply it as both
hookTimeout and testTimeout on the integration Vitest project block only.

  • hookTimeout fixes the concrete npm install / npm run build hook flake.
  • testTimeout gives a matching safe default to the test bodies. Explicit
    per-it() / per-hook timeouts still override it, so nothing regresses.
  • 120000 sits comfortably above every existing per-file value
    (20000 / 40000 / 60000) and above the a2a server timeouts (60000).

The change is deliberately scoped to the integration project rather than the
top-level test block, so the fast unit:* projects keep quick failure
detection. 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:

  • Coverage is N/A: this is a test-runner config-only change. Nothing under
    the coverage include globs (core/src, dev/src, integrations/src) is
    touched, so there are no new instrumented production lines to cover.
  • Intentionally decoupled: follow-up cleanup of the now-redundant per-file
    TEST_EXECUTION_TIMEOUT constants is queued separately and must land after
    this change; the targeted build_setup_test.ts flake fix ships separately.
    This PR edits only vitest.config.ts to avoid coupling a shared-config change
    with those and to avoid merge conflicts.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

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. A
bespoke 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 with
unchanged fast-timeout behavior, confirming the unit:* projects are
unaffected.

Manual End-to-End (E2E) Tests:

Before/after proof that the new hookTimeout is actually in effect, run with no
mocks:

  1. Create a scratch test under tests/integration/ whose beforeAll sleeps 11s
    (longer than the old 10s default) with no explicit per-hook timeout, then
    a trivial it(...).
  2. npx vitest run --project integration <scratch_test> — passes at ~11s
    with this change; fails with Error: Hook timed out in 10000ms. when the
    change is reverted. (Verified both directions locally; the scratch test was
    not committed.)
  3. Real install-heavy suite:
    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 install plus npm run build per fixture) that was most exposed to the
    10s flake.

Tooling gates on the changed file: prettier --check vitest.config.ts (clean)
and eslint vitest.config.ts (clean) both pass; tsc --noEmit reports zero
errors on vitest.config.ts (the change adds no new type errors).

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This PR is config-only: the entire diff is 11 added lines in vitest.config.ts
(a documented INTEGRATION_TIMEOUT_MS constant plus the two fields on the
integration project block).

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
AmaadMartin merged commit 3b3be2f into google:main Jul 31, 2026
12 checks passed
@kalenkevich kalenkevich mentioned this pull request Jul 31, 2026
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.
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.
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants