emscripten-core / emscripten-core/emscripten

emscripten fetch api should be more like JS Fetch API

Open
#12,684 8 comments 4 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Per documentation for Fetch in JavaScript, https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch:
> The Promise returned from fetch() won’t reject on HTTP error status even if the response is an HTTP 404 or 500. Instead, it will resolve normally (with ok status set to false), and it will only reject on network failure or if anything prevented the request from completing.

If the emscripten API is modeled on the JS API, seems that 400 status should go through onsuccess, not onerror.

More generally, the issue with the emscripten Fetch API is the HTTP response with code 4xx will invoke onerror handler instead of onsuccess. Ideally we want onsuccess to be called as long as getting response from the server, and onerror to be called only when getting real error like connection lost, request cancelled, domain resolving failure..etc.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.