fix: uv loop polling when render process reuse enabled (#25869)

This commit is contained in:
Shelley Vohr 2020-10-13 09:19:44 -07:00 committed by GitHub
parent d57cd09f14
commit e8166db9d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View file

@ -108,12 +108,12 @@ void ElectronRendererClient::DidCreateScriptContext(
injected_frames_.insert(render_frame);
// If this is the first environment we are creating, prepare the node
// bindings.
if (!node_integration_initialized_) {
node_integration_initialized_ = true;
node_bindings_->Initialize();
node_bindings_->PrepareMessageLoop();
} else if (reuse_renderer_processes_enabled) {
node_bindings_->PrepareMessageLoop();
}
// Setup node tracing controller.
@ -129,7 +129,7 @@ void ElectronRendererClient::DidCreateScriptContext(
// If we have disabled the site instance overrides we should prevent loading
// any non-context aware native module
if (command_line->HasSwitch(switches::kDisableElectronSiteInstanceOverrides))
if (reuse_renderer_processes_enabled)
env->set_force_context_aware(true);
env->set_warn_context_aware(true);

View file

@ -4286,6 +4286,30 @@ describe('BrowserWindow module', () => {
});
});
describe('reloading with allowRendererProcessReuse enabled', () => {
it('does not cause Node.js module API hangs after reload', (done) => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true
}
});
let count = 0;
ipcMain.on('async-node-api-done', () => {
if (count === 3) {
ipcMain.removeAllListeners('async-node-api-done');
done();
} else {
count++;
w.reload();
}
});
w.loadFile(path.join(fixtures, 'pages', 'send-after-node.html'));
});
});
describe('window.webContents.focus()', () => {
afterEach(closeAllWindows);
it('focuses window', async () => {