mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add ability to close connections for a session (#24945)
These methods are needed for closing all idle and in-flight connections after switching to another proxy from same origin for a session, otherwise these connections may be reused for future requests which is unexpected for most of users.
This commit is contained in:
@@ -295,6 +295,9 @@ Sets the proxy settings.
|
||||
When `pacScript` and `proxyRules` are provided together, the `proxyRules`
|
||||
option is ignored and `pacScript` configuration is applied.
|
||||
|
||||
You may need `ses.closeAllConnections` to close currently in flight connections to prevent
|
||||
pooled sockets using previous proxy from being reused by future requests.
|
||||
|
||||
The `proxyRules` has to follow the rules below:
|
||||
|
||||
```sh
|
||||
@@ -404,6 +407,12 @@ window.webContents.session.enableNetworkEmulation({ offline: true })
|
||||
|
||||
Preconnects the given number of sockets to an origin.
|
||||
|
||||
#### `ses.closeAllConnections()`
|
||||
|
||||
Returns `Promise<void>` - Resolves when all connections are closed.
|
||||
|
||||
**Note:** It will terminate / fail all requests currently in flight.
|
||||
|
||||
#### `ses.disableNetworkEmulation()`
|
||||
|
||||
Disables any network emulation already active for the `session`. Resets to
|
||||
|
||||
Reference in New Issue
Block a user