Repository: electron
Issue: [Bug]: Electron app will crash when loadURL or loadFile is called again
Labels: platform/windows,platform/macOS,bug :beetle:,status/confirmed,has-repro-gist,component/webcontents,20-x-y,28-x-y,29-x-y

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

28.0.0

### What operating system are you using?

Windows

### Operating System Version

Windows 10

### What arch are you using?

x64

### Last Known Working Electron version

_No response_

### Expected Behavior

Correctly load the page

### Actual Behavior

In the gist will crash and report error
```js
Electron exited with code 3221225477.
```

In my project the app will crash and report error
```js
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'start:main'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.1
4 verbose run-script [ 'prestart:main', 'start:main', 'poststart:main' ]
5 info lifecycle electron-react-boilerplate@~prestart:main: electron-react-boilerplate@
6 info lifecycle electron-react-boilerplate@~start:main: electron-react-boilerplate@
7 verbose lifecycle electron-react-boilerplate@~start:main: unsafe-perm in lifecycle true
8 verbose lifecycle electron-react-boilerplate@~start:main: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\yezm\designer\new_designer_electron@11\node_modules\.bin;C:\Users\sendi\AppData\Local\Temp\yarn--1703125317339-0.5654012141646507;D:\yezm\designer\new_designer_electron@11\node_modules\.bin;C:\Users\sendi\AppData\Local\Yarn\Data\link\node_modules\.bin;C:\Program Files\libexec\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\sendi\AppData\Local\Temp\yarn--1703125315075-0.5507023412320058;D:\yezm\designer\new_designer_electron@11\node_modules\.bin;C:\Users\sendi\AppData\Local\Yarn\Data\link\node_modules\.bin;C:\Users\sendi\AppData\Local\Yarn\bin;C:\Program Files\libexec\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\sendi\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\sendi\bin;C:\Python310\Scripts;C:\Python310;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs;C:\Program Files\TortoiseGit\bin;C:\Users\sendi\AppData\Local\Microsoft\WindowsApps;C:\Users\sendi\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sendi\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle electron-react-boilerplate@~start:main: CWD: D:\yezm\designer\new_designer_electron@11
10 silly lifecycle electron-react-boilerplate@~start:main: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'cross-env NODE_ENV=development electron -r ./.erb/scripts/BabelRegister ./src/main.dev.ts'
10 silly lifecycle ]
11 silly lifecycle electron-react-boilerplate@~start:main: Returned: code: 3221225477  signal: null
12 info lifecycle electron-react-boilerplate@~start:main: Failed to exec start:main script
13 verbose stack Error: electron-react-boilerplate@ start:main: `cross-env NODE_ENV=development electron -r ./.erb/scripts/BabelRegister ./src/main.dev.ts`
13 verbose stack Exit status 3221225477
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid electron-react-boilerplate@
15 verbose cwd D:\yezm\designer\new_designer_electron@11
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start:main"
18 verbose node v14.17.1
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 3221225477
22 error electron-react-boilerplate@ start:main: `cross-env NODE_ENV=development electron -r ./.erb/scripts/BabelRegister ./src/main.dev.ts`
22 error Exit status 3221225477
23 error Failed at the electron-react-boilerplate@ start:main script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3221225477, true ]
```



### Testcase Gist URL

https://gist.github.com/Yezhuming/1a52808131145d7db29f0db7a7910a32

### Additional Information

When executing BrowserWindow.loadURL or loadFIle to load a file or web page and the loading has not been completed (success or failure), the Electron app will crash when loadURL or loadFile is called again.

In this gist you can click the test "click here twice quickly" to reproduce this error. Suggest trying when the network is slow or click fast.