You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
UrlLib: Win32/UWP UrlRequest silently succeeds on local-file-not-found (inconsistent with Apple/Android) #167
Filed here because BabylonJS/UrlLib has issues disabled; this issue is about the bundled UrlLib dependency. Move once that repo's issues are enabled, if desired.
Summary
UrlLib's UrlRequest reports local-file-not-found differently across platforms. Two platforms throw; two silently return success with a zero status code.
HTTP non-2xx behavior is consistent (good — that's the W3C-compliant shape: transport succeeded, status code carries the outcome).
Local-file behavior is the bug — callers can't distinguish "file was loaded fine, server returned 0 bytes" from "file does not exist" on Windows family, without falling back to status-code heuristics.
Impact
#165 works around this in the XHR polyfill by treating any status < 200 || status >= 300 as a failure in the error event path. That's a defensible XHR-level decision (XHR has to check status code anyway for HTTP errors), but it papers over the platform inconsistency rather than fixing it. With this workaround in place, all callers via XMLHttpRequest see consistent behavior, but direct UrlLib callers still see the inconsistency.
Proposed fix
Two options, in decreasing order of preference:
Make Win32/UWP throw on local-file-not-found, matching Apple/Android. Callers can catch via arcana::expected::has_error(). This is the most internally consistent behavior and gives callers a clean way to distinguish transport failure from HTTP failure.
Alternatively, standardize on success-task + a synthetic status code (e.g., 404 for missing local file) across all platforms. Less invasive for existing callers, but conflates HTTP and transport semantics.
Either option requires updating Apple/Android in lockstep so all five paths agree.
Closing — incorrect premise on my end. After re-reading the code and seeing @bkaradzic-microsoft's analysis on #165 (comment), the real UrlLib bugs are different from what this issue describes:
Unix — worker std::thread in UrlRequest_Unix.cppstd::terminates on CURLE_FILE_COULDNT_READ_FILE (uncaught std::runtime_error from curl_check).
Apple — UrlRequest_Apple.mmOpen throws synchronously when an app:/// resource isn't found, breaking platform parity vs the deferred-failure pattern everyone else uses.
Win32/UWP do propagate the failure via has_error() (Win32 via ifstream failbit inside make_task; UWP via the WinRT GetFileAsync async error) — not the "silent status-0" path I claimed here.
Activity
bghgary commentedon May 13, 2026
[Filed by Copilot on behalf of @bghgary]
Closing — incorrect premise on my end. After re-reading the code and seeing @bkaradzic-microsoft's analysis on #165 (comment), the real UrlLib bugs are different from what this issue describes:
std::threadinUrlRequest_Unix.cppstd::terminates onCURLE_FILE_COULDNT_READ_FILE(uncaughtstd::runtime_errorfromcurl_check).UrlRequest_Apple.mmOpenthrows synchronously when anapp:///resource isn't found, breaking platform parity vs the deferred-failure pattern everyone else uses.Win32/UWP do propagate the failure via
has_error()(Win32 viaifstreamfailbit insidemake_task; UWP via the WinRTGetFileAsyncasync error) — not the "silent status-0" path I claimed here.Continuing the discussion on #165.