Question about sending parallel network requests from Chrome extension

197 views
Skip to first unread message

Codrin Iftode

unread,
Apr 20, 2023, 12:48:54 PM4/20/23
to Chromium Extensions
I have been developing a Chrome extension which connects to a back-end service via an API. Four different requests need to be sent, ideally in parallel for efficiency, to this API.

I wrote a function based on Promises that can send these requests, using Promise.all. When I run it on Firefox, the requests arrive at the API at the same time (hence, they are parallel). However, when the same code runs on Chrome, the requests arrive at the API sequentially, based on API logs. This is strange, especially since the Network tab in the Chrome Developer Tools shows that the requests were dispatched at the same time.

Therefore, I thought the problem might be internal to Chrome. Is there any chance Chrome still internally processes the requests sequentially?

Thank you for your help!

wOxxOm

unread,
Apr 20, 2023, 5:05:40 PM4/20/23
to Chromium Extensions, Codrin Iftode
Try using an external tool like Fiddler or Charles or WireShark and try finding any difference in the headers or the transport itself (e.g. HTTP3 vs H2).

Oliver Dunk

unread,
Apr 21, 2023, 6:12:45 AM4/21/23
to Codrin Iftode, Chromium Extensions
Hi Codrin,

This is a super interesting question!

After having a play on my side, I have an idea - can you try setting the Cache-Control header to no-cache in your fetch call? For example:

fetch("http://localhost:8000/", { headers: { "Cache-Control": "no-cache" } })

Using the "disable cache" checkbox in Dev Tools should also have the same effect.

What I've learnt is that Chrome can sometimes hold one request to see if it can use cached responses from the previous ones. I haven't found a canonical reference for this but there's some discussion in https://stackoverflow.com/a/27514611/5012509.

That said - while I want to rule this out, it might not be what's happening for you, since it sounds like each of your requests is probably unique. If that's the case, we may need to keep thinking.
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/48a4974d-6863-4d6f-82ff-fd6c3c15857en%40chromium.org.

Codrin Iftode

unread,
Apr 26, 2023, 5:46:31 AM4/26/23
to Chromium Extensions, Oliver Dunk, Chromium Extensions, Codrin Iftode
Hi both, thank you very much for your suggestions! I tried adding the cache-control header, but it made no difference... I changed it to different values, as suggested by the Stack Overflow thread, but that did not help either. 
I also tried playing with the User Agent, but again to no avail.
I will have a call with our back-end developer, and check how the requests are looking from the other side. Do you have any other ideas as far as the front-end is concerned?

Oliver Dunk

unread,
Apr 26, 2023, 7:28:14 AM4/26/23
to Codrin Iftode, Chromium Extensions
Hmm, strange.

Unfortunately I can't immediately think of anything else.

If you could share some sample code and maybe even a video reproducing that would definitely be useful.

Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Patrick Kettner

unread,
Apr 30, 2023, 9:32:08 AM4/30/23
to Codrin Iftode, Chromium Extensions, Oliver Dunk
If you could share the har file of the extensions session while this is happening, it could potentially give some insight

Reply all
Reply to author
Forward
0 new messages