-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emscripten_fetch returns id 0 if not used with EMSCRIPTEN_FETCH_REPLACE #23124
Comments
Looking at the logic flow in Fetch.js, we have: Lines 559 to 562 in d5c419f
In the case that Line 308 in d5c419f
The trouble is that if Lines 165 to 174 in d5c419f
Only at this point do we call the I think it might make more sense, if there's a possibility that an xhr will be made, to allocate an id anyway with |
Note if I set |
Yes, it looks like I'm also not sure why we need an ID at all since the address of the |
BTW, as the user of the API, why do you care about the ID that is stored in the struct? Don't all the callbakc functions take a unique |
The use case for the ID for me is to match up multiple concurrent fetches between their invocation and subsequent callbacks without having to allocate and manage individual userdata for each call. A typical use is as a key in a map, representing the state of multiple ongoing downloads. You make an interesting point, though - if the address of the The other aspect of the |
You are correct that that address of the I would not be averse to patch to make the id allocation earlier in the call stack, but if you want a quick fix that works today I would just go with using the pointer as the key in your map. |
Tested with version 3.1.73.
When calling
emscripten_fetch
with any combination of attributes, but without usingEMSCRIPTEN_FETCH_REPLACE
, theemscripten_fetch_t
struct it returns always has theid
member set to0
. WithEMSCRIPTEN_FETCH_REPLACE
, these increment normally.Callbacks receive the correct
id
in all cases, just the struct initially returned byemscripten_fetch
is wrong.Minimal example to reproduce:
The text was updated successfully, but these errors were encountered: