Repository navigation
fix: net requests failing in utility process after network service re… - #49215
loufultoncz-coder wants to merge 9 commits into
Conversation
deepak1556
left a comment
There was a problem hiding this comment.
Great catch! would need some refactor around re-creating the factory, additionally some high level questions
- What error codes do the active requests get when network process crashes
- What does the renderer process do today when it detects the network process crashes, does it also reset the factories ?
- Is there a test case that we can add as part of the PR ?
| mojo::GenericPendingReceiver receiver) { | ||
| if (auto r = receiver.As<network::mojom::URLLoaderFactory>()) { | ||
| LOG(INFO) << "utility process bind network::mojom::URLLoaderFactory"; | ||
| mojo::PendingRemote<network::mojom::URLLoaderFactory> url_loader_factory; |
There was a problem hiding this comment.
- There is duplication of the factory params here and in
api::UtilityProcessWrapper - We are not passing the
URLLoaderNetworkObserverassociated with the utility process anymore which would break login events after restart
Both of these can be solved by extracting the api::UtilityProcessWrapper in ElectronBrowserClient::BindUtilityHostReceiver with base::ProcessId via the global map maintained currently api::UtilityProcessWrapper::FromProcessId. But to get base::ProcessId we need to adjust the callsite https://source.chromium.org/chromium/chromium/src/+/main:content/browser/service_host/utility_process_host_receiver_bindings.cc;l=43 to also pass the content::UtilityProcessHost then the associated process id can be extracted from content::BrowserChildProcessHost via process_->GetData().GetProcess()
Hi @deepak1556 , thank you for raising these questions — I’ve looked into the current behavior and wanted to share what I found:
When the network process crashes, in-flight requests are aborted and typically surface as generic network failures (e.g. ERR_FAILED / ERR_ABORTED) to the caller. The exact error depends on the request state at the time of the crash, but there is no graceful recovery for active requests today — they fail and need to be re-issued once the network service is back.
On the renderer side, this is handled in RenderFrameHostImpl::CreateNetworkServiceDefaultFactoryAndObserve This ensures renderer-side network interfaces are re-bound via Mojo.
There isn’t currently a targeted test covering utility/network process |
|
Thanks for the followup,
|
Thanks for your feedback! It seems that content::RegisterNetworkServiceProcessGoneHandler is primarily intended for internal use within the content module and is not publicly exposed via content/public/browser/network_service_instance.h. After considering other alternatives, I opted for current change as a minimal and effective approach. |
|
You can use exported functions from |
Thanks for the suggestion. I’ve updated the logic following this approach, and I plan to add the unit tests tomorrow. |
|
@deepak1556 Thank you for pointing this out. While investigating this issue, I noticed that the same problem also exists in the browser process — the cached URLLoaderFactory can become invalid after the Network Service restarts, leading to similar request failures. I’ve addressed this as well in the latest commit, where the browser-side factory is reset and rebound when the Network Service connection is lost, so requests can recover correctly without requiring a process restart. Please let me know if this approach looks reasonable to you, or if you’d prefer handling the browser and utility processes differently. Happy to make adjustments based on your feedback. |
|
Hi @deepak1556 I’ve added a new test case to address the issue we discussed earlier. Could you please take another look when you have a moment? Your feedback would be much appreciated. Let me know if you have any questions or need further changes! Thanks in advance! |
|
Hi @deepak1556 , I noticed this PR has been open for a while, can you take a look when you have time? Thanks! |
|
Apologies for the delay, the PR is on the top of my list to review for this week. |
35c8821 to
695a4f2
Compare
|
@loufultoncz-coder the changes were revisited as part of #49887. Thank you for your contribution, we will ensure to capture it in our release notes. |
Description of Change
Fix an issue where the
netmodule in the utility process fails to send any network requests after the Network Service process crashes and is restarted.The utility process caches a
URLLoaderFactoryinstance that becomes invalid once the Network Service is recreated. Since the utility process is not restarted and the cached factory is not refreshed, all subsequentnetrequests fail.This change ensures that the cached
URLLoaderFactoryis properly reset and rebound when the Network Service connection becomes invalid, allowing network requests to recover automatically without requiring a utility process restart.Checklist
npm testpassesRelease Notes
Notes: Fixed an issue where
netrequests could fail permanently after the Network Service process crashed and restarted.