Skip to content

Better error messages for wasm network errors#145

Merged
ianthomas23 merged 1 commit intomainfrom
better-wasm-errors
Apr 22, 2026
Merged

Better error messages for wasm network errors#145
ianthomas23 merged 1 commit intomainfrom
better-wasm-errors

Conversation

@ianthomas23
Copy link
Copy Markdown
Member

This PR uses better error messages for wasm network errors. These error messages occur on the JavaScript side and are passed back to the C++ for display on stderr. Unfortunately some of the error messages are not very informative for end users, such as if there isn't a CORS proxy:

js-shell: git clone https://github.com/ianthomas23/cockle-playground
Cloning into 'cockle-playground'...
error: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://github.com/ianthomas23/cockle-playground/info/refs?service=git-upload-pack'.

This error is now displayed as:

js-shell: git clone https://github.com/ianthomas23/cockle-playground
Cloning into 'cockle-playground'...
error: network error sending request to https://github.com/ianthomas23/cockle-playground/info/refs?service=git-upload-pack, see the browser console and/or network tab for more details

Unfortunately we cannot be more specific as the real reason for a failed XMLHttpRequest.send is browser-specific and is not available via a standard browser JavaScript API. Some browsers report something useful in the browser console, others don't, and usually there is something useful but necessarily technical in the browser dev tools network tab.

Longer term we can probably do better than this, but for now it is at least an improvement on the current behaviour.

I have tested this manually on chrome, firefox and safari.

Closes #130.

@ianthomas23 ianthomas23 added the enhancement New feature or request label Apr 22, 2026
@ianthomas23 ianthomas23 marked this pull request as ready for review April 22, 2026 12:34
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.22%. Comparing base (85b406f) to head (b1df300).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
- Coverage   88.27%   88.22%   -0.06%     
==========================================
  Files          61       61              
  Lines        2730     3065     +335     
  Branches      330      330              
==========================================
+ Hits         2410     2704     +294     
- Misses        320      361      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ianthomas23
Copy link
Copy Markdown
Member Author

WebAssembly tests passing: https://github.com/QuantStack/git2cpp/actions/runs/24778479938

Codecov fails as we don't have a way of measuring code coverage in the wasm build.

@ianthomas23 ianthomas23 merged commit 5ec6e88 into main Apr 22, 2026
9 of 11 checks passed
@ianthomas23 ianthomas23 deleted the better-wasm-errors branch April 22, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error messages for network errors

2 participants