Skip to content

fix(claude_hooks): skip binary downloads and bypass bazelisk in tests#684

Draft
agentydragon wants to merge 1 commit intodevelfrom
claude/fix-test-session-start-TMDVy
Draft

fix(claude_hooks): skip binary downloads and bypass bazelisk in tests#684
agentydragon wants to merge 1 commit intodevelfrom
claude/fix-test-session-start-TMDVy

Conversation

@agentydragon
Copy link
Copy Markdown
Owner

The e2e tests in test_session_start.py each run the full session_start hook with an isolated XDG_CACHE_HOME. This caused every test to download bazelisk (~30MB) and mkcert (~10MB) from GitHub, making the 5 e2e tests exceed the 300s medium test timeout on slow connections.

Fix:

  • Add ENV_INSTALL_MKCERT constant to settings.py (parallel to the existing ENV_INSTALL_BAZELISK / ENV_INSTALL_NIX constants).
  • Set INSTALL_BAZELISK=0, INSTALL_MKCERT=0, INSTALL_NIX=0 in _setup_hook_env to skip all binary downloads in tests.
  • With INSTALL_BAZELISK=0, the hook falls back to shutil.which("bazelisk") as BAZELISK_PATH. When the inner bazel build runs, bazelisk reads .bazelversion (7.6.0) and tries to download that version from GitHub through the mock proxy, which rejects it → TimeoutError.
  • Add _find_cached_bazel_binary() to locate a pre-downloaded Bazel binary from bazelisk's download cache (XDG_CACHE_HOME/bazelisk/downloads/). Set SYSTEM_BAZEL to that binary before isolating XDG_CACHE_HOME so the hook writes it as BAZELISK_PATH; the wrapper then execs the real Bazel binary directly, bypassing bazelisk version resolution entirely.

https://claude.ai/code/session_0126q6Mf9xdKsYR6NzAH6WgT

The e2e tests in test_session_start.py each run the full session_start
hook with an isolated XDG_CACHE_HOME. This caused every test to download
bazelisk (~30MB) and mkcert (~10MB) from GitHub, making the 5 e2e tests
exceed the 300s medium test timeout on slow connections.

Fix:
- Add ENV_INSTALL_MKCERT constant to settings.py (parallel to the
  existing ENV_INSTALL_BAZELISK / ENV_INSTALL_NIX constants).
- Set INSTALL_BAZELISK=0, INSTALL_MKCERT=0, INSTALL_NIX=0 in
  _setup_hook_env to skip all binary downloads in tests.
- With INSTALL_BAZELISK=0, the hook falls back to shutil.which("bazelisk")
  as BAZELISK_PATH. When the inner bazel build runs, bazelisk reads
  .bazelversion (7.6.0) and tries to download that version from GitHub
  through the mock proxy, which rejects it → TimeoutError.
- Add _find_cached_bazel_binary() to locate a pre-downloaded Bazel binary
  from bazelisk's download cache (XDG_CACHE_HOME/bazelisk/downloads/).
  Set SYSTEM_BAZEL to that binary before isolating XDG_CACHE_HOME so the
  hook writes it as BAZELISK_PATH; the wrapper then execs the real Bazel
  binary directly, bypassing bazelisk version resolution entirely.

https://claude.ai/code/session_0126q6Mf9xdKsYR6NzAH6WgT
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