Skip to content

debugger: Fall back to cached adapter binaries when offline#50928

Merged
Veykril merged 3 commits intozed-industries:mainfrom
nihalxkumar:fix/debugger-offline-fallback
Mar 16, 2026
Merged

debugger: Fall back to cached adapter binaries when offline#50928
Veykril merged 3 commits intozed-industries:mainfrom
nihalxkumar:fix/debugger-offline-fallback

Conversation

@nihalxkumar
Copy link
Copy Markdown
Contributor

The Python (debugpy) and Go (delve-shim-dap) debug adapters unconditionally require network access on every debug session start — even when the adapter binary is already cached locally. This makes the debugger completely unusable offline.

Python: fetch_debugpy_whl → maybe_fetch_new_wheel hits pypi; failure propagates as a fatal error.
Go: install_shim → fetch_latest_adapter_version hits the GitHub API; failure propagates as a fatal error.
CodeLLDB and JavaScript adapters already handle this correctly.

Fix for Python and Go:

Wrap the network fetch in each adapter with a fallback: if the request fails and a previously downloaded adapter exists on disk, log a warning and use the cached version. If no cache exists, the original error propagates unchanged.

Logs after the fix:

2026-03-06T16:31:51+05:30 WARN  [dap_adapters::python] Failed to fetch latest debugpy, using cached version: getting latest release
2026-03-06T16:31:51+05:30 INFO  [dap::transport] Debug adapter has connected to TCP server 127.0.0.1:45533

Limitations:

The debugger must be run at least once with internet connectivity to populate the cache on disk. This PR does not change that requirement.

Closes #45781

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
    • No automated tests are included. The existing MockDelegate stubs http_client() and fs() as unimplemented!(), so testing the fallback path would require new mock infrastructure. The fix was verified manually by running the debug build offline with and without cached adapters. The CodeLLDB adapter's equivalent fallback (lines 357-374) also has no dedicated test.
  • Done a self-review taking into account security and performance aspects

Release Notes:

  • Fixed debugger failing to start when offline if a debug adapter was previously downloaded.

.join("adapter");

if let Err(error) = self.maybe_fetch_new_wheel(toolchain, delegate).await {
if adapter_path.exists() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if adapter_path.exists() {
if delegate.fs().metadata().is_ok_and(Option::is_some)) {

and for the go module as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you
fixed

@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 16, 2026
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Thanks!

@Veykril Veykril enabled auto-merge (squash) March 16, 2026 15:53
@nihalxkumar
Copy link
Copy Markdown
Contributor Author

sending for CI

auto-merge was automatically disabled March 16, 2026 16:17

Head branch was pushed to by a user without write access

@Veykril Veykril enabled auto-merge (squash) March 16, 2026 16:22
@Veykril Veykril merged commit 74dbaeb into zed-industries:main Mar 16, 2026
29 checks passed
@nihalxkumar nihalxkumar deleted the fix/debugger-offline-fallback branch March 16, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debugger doesn't work offline

5 participants