-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event 'open' on app is triggered once #7860
Comments
I am also seeing this issue. It happens with 0.63.0 in both Linux and Windows. An odd error message is also appearing, every time the app is launched:
|
I created a test to find this regression and it helped narrow-down the behavior. It seems that any event handlers attached to the This shows the bug in action. After the first const util = require('util');
const exec = util.promisify(require('child_process').exec);
let eventFired;
nw.App.on('open', (params) => {
console.log('params', params);
eventFired = true;
});
const testOpenEvent = async () => {
eventFired = false;
const result = await exec(`${process.argv} ${nw.App.startPath} --testing`);
if (!eventFired) return false;
return true;
};
(async () => {
for (let i = 0; i <= 5; i++) {
console.log(`Test attempt: ${i}`);
if (! await testOpenEvent()) {
console.log('FAIL: The `open` event did not fire!');
}
}
})(); However, if the event handler is re-attached to the const util = require('util');
const exec = util.promisify(require('child_process').exec);
const testOpenEvent = async () => {
let eventFired = false
nw.App.on('open', (params) => {
console.log('params', params);
eventFired = true;
});
const result = await exec(`${process.argv} ${nw.App.startPath} --testing`);
if (!eventFired) return false;
return true;
};
(async () => {
for (let i = 0; i <= 5; i++) {
console.log(`Test attempt: ${i}`);
if (! await testOpenEvent()) {
console.log('FAIL: The `open` event did not fire!');
}
}
})(); |
Maybe same issue with other events like |
On macOS the reopen event is fired only the first time when you click on the app icon in the dock after initial app start, in versions prior to 0.63.0 it was firing every time |
Any news? |
This is caused by https://chromium-review.googlesource.com/c/chromium/src/+/3233175 |
This is fixed in git and will be available in the next nightly build. |
I have fixed this issue by adding my function in nw.App.onOpen.addListener and in this case it doesn't remove the listener. |
Win 10 (x64)
manifest.json:
init.js:
test case:
@rogerwang
The text was updated successfully, but these errors were encountered: