I am developing a simple electron program. It takes a user input from a website, processes it using a callback function, and either returns an error or null
(for no error). The callback function calls event.reply
to send the result back to the page, however the event.reply
does not throw an error or run the code specified in the reply.
Node integration is set to true
and context isolation has been set to false
.
The actual function with a callback, as well as the page’s HTML code, have not been given. I have extensively tested both in a vacuum, and both are not the problem.
pageRenderer.js
submit = document.getElementById('submit');
ipcRenderer.on('returnInfo', (event, isSuccess) => {
if (isSuccess) {
alert('Success!');
} else { //Login failed
alert('Failure!');
}
});
submit.addEventListener('click', (event) => {
const userInput = document.getElementById('input').value;
ipcRenderer.send('Process', (userInput));
});
main.js
ipcMain.on('Process', (event, userInput) => {
globalVariable = userInput
processValue((err) => {
if (err) {
console.error(err);
event.reply('returnInfo', false);
} else {
event.reply('returnInfo', true);
}
});
});
When running the program, I tested that the if statement in the ipcMain
function works correctly, depending on if processValue
succeeds or not. However, the ipcRenderer
function does not run and does not throw a runtime error.