Issue 1:
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 an issue that matches the one I want to file, without success.

Issue Details

Electron Version: v10.1.1 (also present in v9)

Operating System: macOS 10.15.5

Actual Behavior

Node.js timers stop working indefinitely after running Electron for a while. This breaks all async Node.js functions like fs.readFile, fs.promises.readFile, and http.get:

In case it's not clear in the screenshot, window.setTimeout works but the Node.js version of setTimeout doesn't.

fs.readFileSync and synchronous functions continue to work fine:

To Reproduce

It's hard to reproduce. This issue happens randomly but frequently enough. It could happen after 10 seconds of launching Electron or after 1 hour.

Additional Information

allowRendererProcessReuse is set to true. I use 3 native modules in the renderer process: keytar, node-mac-contacts and node-mac-permissions. All 3 modules are up to date.

Only refreshing (⌘ R) fixes this and gets everything to work again.

Issue 2:
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 an issue that matches the one I want to file, without success.

Issue Details

Electron Version:

8.0.0

Operating System:

Windows 10 (1809)

Last Known Working Electron version:

Unknown

When setting app.allowRendererProcessReuse = true and after reloading the renderer (Ctrl+R in developer console), Node fs APIs would randomly stop working. Specifically, the callbacks are never called, or if you're using fs.promises, the promises are never resolved.

An interesting observation is: when you reload again, for a brief moment before the page is refreshed, the previous fs calls are magically unblocked. This can be observed by console.log lines suddenly printing the moment you hit Ctrl+R which disappears quickly as the whole page reloads.

Possibly related: #19554 This issue sounds like the opposite of what's happening here.

Also note: issue does not present itself when app.allowRendererProcessReuse = false

Expected Behavior

From the repro steps, expecting to see local files printed in the console:

...
renderer.js:8 Reading file main.js
renderer.js:8 Reading file package-lock.json
renderer.js:8 Reading file package.json
renderer.js:8 Reading file preload.js
renderer.js:8 Reading file README.md
renderer.js:8 Reading file renderer.js
renderer.js:14 done

Actual Behavior

List is printed the first time the app loads. Hit Ctrl+R and observe only a few lines printed, or none at all. Hit Ctrl+R again and observe more lines printed for a split second before renderer reloads.

To Reproduce

Clone https://github.com/electron/electron-quick-start

rendereer.js

(async () => {
const fs = require('fs').promises;

for (let i = 0; i < 10; i++) {
let list = await fs.readdir('.', {withFileTypes: true});
for (let file of list) {
if (file.isFile()) {
console.log('Reading file', file.name);
await fs.readFile(file.name, 'utf-8');
}
}
}

console.log('done');
})();

main.js

const {app, BrowserWindow} = require('electron');

function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
});

win.loadFile('index.html');
win.webContents.openDevTools();
}

app.whenReady().then(createWindow);

app.allowRendererProcessReuse = true;
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

Screenshots

First boot:

On reload:

Additional Information