Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
15.0.2
What operating system are you using?
Ubuntu
Operating System Version
Linux rrouwprlc0068 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux, Ubuntu 20.04.3 LTS, GNOME Version 3.36.8, OS Type 64-bit
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Network service should not crash and the error [15:1102/154337.143944:ERROR:network_service_instance_impl.cc(333)] Network service crashed, restarting service., to not appear in the logs.
Actual Behavior
Sporadically, when I run Electron inside a Docker container, I get the following error:
[15:1102/154337.143944:ERROR:network_service_instance_impl.cc(333)] Network service crashed, restarting service.
Which causes partially rendering of the front-end application that is loaded with win.loadURL on localhost.
The issue seems very similar to https://bbs.archlinux.org/viewtopic.php?id=268123, but nothing from the suggestions works consinstently.
Also, when closing the Electron window, I get an error
Error: ERR_FAILED (-2) loading 'https://localhost:{port}/{path_to}/index.html'
at rejectAndCleanup (node:electron/js2c/browser_init:165:7486)
at Object.stopLoadingListener (node:electron/js2c/browser_init:165:7861)
at Object.emit (node:events:394:28) {
errno: -2,
code: 'ERR_FAILED',
url: 'https://localhost:{port}/{path_to}/index.html'
} [EOL]
Which is caught inside the main.js when executing await win.loadURL(url)
Also, in the browser window console, there is an error:
ERROR Error: Uncaught (in promise): ChunkLoadError: Loading chunk 108 failed.
(timeout: https://localhost:{port}/{path_to}/108.da4993913b4a27951976.js)
ChunkLoadError: Loading chunk 108 failed.
Any ideas on the issue?
Testcase Gist URL
No response
Additional Information
Chromedriver 95.0.0 v
Activity
[-][Bug]: [/-][+][Bug]: Network service crashed, restarting service.[/+]zcbenz commentedon Nov 3, 2021
Will you see the same error if you run chromium browser in docker?
https://download-chromium.appspot.com/?platform=Linux_x64&type=snapshots
DrNio13 commentedon Nov 3, 2021
Probably not. Can it be related to SignalR/Web Socket connection?
The error occurs only in certain situation, when Electron loads an Angular app with win.loadURL while the backend services are already running and the Network Service crashed error occurs somewhere near trying to establish a signalR connection.
Browser logs
DrNio13 commentedon Nov 3, 2021
I managed to find what triggers the issue, not sure about the root cause though.
Here is a part of the
main.tsfile based on https://www.electronjs.org/docs/tutorial/quick-startApparently the issue disappears when commenting out the
setCertificateVerifyProchook. Any ideas why?I tried setting it also to
callback(0)but the issue still occurred sporadically.Couple of more questions/thoughts.
Omitting this hook from
main.tsis the same as calling it likesetCertificateVerifyProc(null)?Also, from the logs I was able to see that at least 2 requests were executed before the
setCertificateVerifyProchook. I would expect the hook to be executed before any http requests. Is this a bug?According to the logs, the hook seems to be called twice. Is this a bug?
Thanks for the support :)
lauw70 commentedon Feb 21, 2022
I can confirm that this sporadic issue is triggered by setting the setCertificateVerifyProc hook.
We are running into this issue on both Mac and Windows on v16.0.2 and v17.0.1
lauw70 commentedon Mar 8, 2022
@zcbenz
@DrNio13
I made two Fiddles:
The difference is in the setCertificateVerifyProc handler:
My hypothesis on why this bug happens
If you load a page (
loadURL()) that subsequently loads numerous resources from a different hostname. The handler is called multiple times for the same hostname causing a read/write race condition or an asynchronous write to the cache that stores the verification results per hostname. This causes the network service to crash (see logs below).Log from Fiddle 1
Note how the page stops loading once the network service crashes. We would expect many more domains to be verified, since this particular URL loads resources from many other domains.
Logs from Fiddle 2
lauw70 commentedon Mar 8, 2022
I managed to reproduce the bug on these versions:
using the first Fiddle.
Sometimes have you to run it a couple of times for the bug to show.
lauw70 commentedon Mar 8, 2022
@nornagon This seems to be related to a patch you made a year ago: #28358
nornagon commentedon Mar 8, 2022
Crash dump:
That's crashing here, so
verify_resultmust be bad by the timeAddResultToCacheis called.Looks like what's happening is that the SSLClientSocketImpl is getting destroyed while the CertificateVerifyProc is in-flight due to a SPDY upgrade:
We should be able to detect this and tear down the in-flight verify request gracefully when the underlying socket is destroyed to avoid crashing.
nornagon commentedon Mar 8, 2022
Looks like the way to get notified about request cancellation is by setting
out_reqto something here:electron/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch
Line 49 in e41c3e9
Destruction of that object signals cancellation: https://source.chromium.org/chromium/chromium/src/+/main:net/cert/cert_verifier.h;l=83;drc=459dba1945dd88c8dd98c6fbfd617f84e62eba99
CoalescingCertVerifier's logic is a bit complicated but does use this signal, as an example in upstream.
nornagon commentedon Mar 9, 2022
@lauw70 thanks for the detailed repro steps. I was able to track down the cause of the issue and #33204 fixes it I believe.
lauw70 commentedon Mar 9, 2022
@nornagon thank you so much for putting in the time. Currently this is last blocking bug for our next production release. You can't imagine how much this helps us out.
I'm almost afraid to ask, but how much time does it usually take before a PR like this hits a stable release?