Skip to content

[codex] Make version checks asynchronous and optional - #3286

Open
hengyunabc wants to merge 2 commits into
masterfrom
codex/async-version-check
Open

hengyunabc wants to merge 2 commits into
masterfrom
codex/async-version-check

Conversation

@hengyunabc

@hengyunabc hengyunabc commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Arthas checks for updates while rendering the welcome message and waits up to two seconds for each check. This can delay startup and tunnel client connections, and there is no way to disable the request inside the target JVM.

Move the check to the end of bootstrap initialization and run it once on a dedicated daemon thread without waiting. A successful check logs the version; a failed check logs at debug level. Neither path schedules another attempt. Accept only a final HTTP status of 200, so unfollowed redirects and other non-200 responses cannot be logged as version data. Check interruption between response reads, close the response stream and connection, and interrupt the worker when Arthas stops.

Add arthas.checkLatestVersion, enabled by default. Setting it to false prevents creation of the worker and the version-check request, including its DNS lookup. Document configuration, response handling, and cancellation limits in Chinese and English.

The background thread still runs inside the target JVM. This change does not fix native DNS crashes or guarantee termination of a stuck native call. Connection and read timeouts are not an overall deadline; affected environments must disable the check. arthas-boot download/version-selection requests are unchanged.

Run the welcome-message network interception test in an isolated JVM so its global proxy selector cannot intercept workers started by other tests.

Fixes #2973.
Related to #3021, including #3021 (comment).

Validation:

  • The original welcome-message regression test failed against the original code (3 unexpected version requests).
  • The new non-200 response and interrupted-read regressions failed before the fixes and pass afterward.
  • JDK 17: ./mvnw -pl core -am test -Dtest=ArthasBannerTest,ConfigureTest,ArthasBootstrapTest,EnhancerLineTest -Dsurefire.failIfNoSpecifiedTests=false — 19 tests passed.
  • Tests cover nonblocking submission, success/failure termination, 302/304/204/500 rejection, interrupted reads and resource cleanup, disabled checks, configuration binding/serialization, and an isolated welcome-message probe.
  • A local HTTP reproduction verified cross-protocol 302 rejection and worker exit after interruption while the server continued sending data. A standalone concurrent-request check verified that the isolated banner test leaves unrelated requests alone.
  • npm --prefix site run docs:build — passed.
  • git diff --check — passed.

@hengyunabc
hengyunabc requested a max review from Copilot November 4, 2026 02:12
@hengyunabc
hengyunabc marked this pull request as ready for review November 4, 2026 02:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T02:14:16.632119Z 04ff544 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved issues can cause redirect pages to be logged as version data, cross-test interference through the global proxy selector, and worker/classloader retention after shutdown.

3 open issues
What changed in this PR

Moves Arthas’s target-JVM version check out of welcome-message rendering into an optional background task, avoiding network waits during startup and client connections.

Changes:

  • Add the default-enabled arthas.checkLatestVersion setting.
  • Run a one-shot daemon worker with HTTP resource cleanup and shutdown interruption.
  • Add regression tests and bilingual documentation covering configuration and target-JVM limitations.
File Description
site/​docs/​en/​doc/​arthas-properties.md Document configuration options and limitations in English.
site/​docs/​doc/​arthas-properties.md Document configuration options and limitations in Chinese.
core/​src/​test/​java/​com/​taobao/​arthas/​core/​util/​ArthasBannerTest.java Test network-free banners, asynchronous checks, and resource cleanup.
core/​src/​test/​java/​com/​taobao/​arthas/​core/​server/​ArthasBootstrapTest.java Test that disabling checks prevents worker creation.
core/​src/​test/​java/​com/​taobao/​arthas/​core/​config/​ConfigureTest.java Test defaults, binding, and configuration serialization.
core/​src/​main/​java/​com/​taobao/​arthas/​core/​util/​ArthasBanner.java Replace banner-triggered checks with an asynchronous worker.
core/​src/​main/​java/​com/​taobao/​arthas/​core/​server/​ArthasBootstrap.java Start the configured check and interrupt its worker during teardown.
core/​src/​main/​java/​com/​taobao/​arthas/​core/​config/​Configure.java Add the version-check configuration property.
core/​src/​main/​java/​arthas.properties Add a commented example for disabling version checks.

Review effort: Max

Comment on lines +173 to +175
// Use the JDK's bounded redirect handling instead of recursive requests.
connection.setInstanceFollowRedirects(true);
try (InputStream inputStream = connection.getInputStream()) {
// Use the JDK's bounded redirect handling instead of recursive requests.
connection.setInstanceFollowRedirects(true);
try (InputStream inputStream = connection.getInputStream()) {
return com.taobao.arthas.common.IOUtils.toString(inputStream).trim();
Comment on lines +43 to +46
if ("arthas.aliyun.com".equals(uri.getHost())) {
requests.incrementAndGet();
// Fail before DNS or network I/O, even when testing the old implementation.
throw new IllegalStateException("Unexpected version check while rendering the welcome message");

This branch has not been deployed

No deployments
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.

ArthasBootstrap.getInstance(instrumentation, "") 如何禁止调用/api/latest_version

2 participants