|
8 | 8 | # include <emscripten.h> |
9 | 9 |
|
10 | 10 | # include "../utils/common.hpp" |
| 11 | +# include "constants.hpp" |
11 | 12 | # include "response.hpp" |
12 | 13 |
|
13 | 14 | // Buffer size used in transport_smart, hardcoded in libgit2. |
@@ -106,7 +107,7 @@ EM_JS( |
106 | 107 | // clang-format off |
107 | 108 | Module["git2cpp_js_error"] = { name: err.name ?? "", message : err.message ?? "" }; |
108 | 109 | // clang-format on |
109 | | - console.error(err); |
| 110 | + (err.name == "TimeoutError" ? console.warn : console.error)(err); |
110 | 111 | return -1; |
111 | 112 | } |
112 | 113 | } |
@@ -208,7 +209,7 @@ EM_JS( |
208 | 209 | // clang-format off |
209 | 210 | Module["git2cpp_js_error"] = { name: err.name ?? "", message : err.message ?? "" }; |
210 | 211 | // clang-format on |
211 | | - console.error(err); |
| 212 | + (err.name == "TimeoutError" ? console.warn : console.error)(err); |
212 | 213 | return -1; |
213 | 214 | } |
214 | 215 | } |
@@ -245,7 +246,7 @@ EM_JS(size_t, js_write, (int request_index, const char* buffer, size_t buffer_si |
245 | 246 | // clang-format off |
246 | 247 | Module["git2cpp_js_error"] = { name: err.name ?? "", message : err.message ?? "" }; |
247 | 248 | // clang-format on |
248 | | - console.error(err); |
| 249 | + (err.name == "TimeoutError" ? console.warn : console.error)(err); |
249 | 250 | return -1; |
250 | 251 | } |
251 | 252 | }); |
@@ -273,6 +274,16 @@ static void convert_js_to_git_error(wasm_http_stream* stream) |
273 | 274 | stream->m_unconverted_url.c_str() |
274 | 275 | ); |
275 | 276 | } |
| 277 | + else if (std::string_view(error_str).starts_with("TimeoutError:")) |
| 278 | + { |
| 279 | + git_error_set( |
| 280 | + GIT_ERROR_HTTP, |
| 281 | + "network request timed out connecting to %s. You can set a longer timeout in seconds using the environment variable %s, the default value is %u seconds.", |
| 282 | + stream->m_unconverted_url.c_str(), |
| 283 | + WASM_HTTP_TRANSPORT_TIMEOUT_NAME.data(), |
| 284 | + WASM_HTTP_TRANSPORT_TIMEOUT_DEFAULT_S |
| 285 | + ); |
| 286 | + } |
276 | 287 | else |
277 | 288 | { |
278 | 289 | git_error_set(GIT_ERROR_HTTP, "%s", error_str); |
|
0 commit comments