Repository navigation
Quit anyway: don't wait for the abandoned work before shutting down - #162
Conversation
Quit anyway says the work is left unfinished, but when a VM was also running, Shut down VMs and quit still waited for that VM's work before pressing its power button. A profile save can take minutes, so the quit looked stuck with the window already in the tray. The work question now returns which VMs' work was abandoned (Quit anyway, or Quit now in the tray while waiting), and the shutdown presses the power button on those right away. Work that starts after the question, or that the user chose to wait for, is still waited for as before.
Covers the tray's Quit and the window's close with the quit close behavior, and that work which starts on another VM after the question is still waited for.
A21-devs
left a comment
There was a problem hiding this comment.
The direction is right and the tests cover the orderings in the issue. Two problems, the first one real enough to fix before merging.
| // only makes the quit look stuck, and a hibernate the power button turns into a shutdown is fine | ||
| await Promise.all( | ||
| names.map(async (n) => { | ||
| if (abandoned.has(n)) return this.pressPower(n) |
There was a problem hiding this comment.
The abandoned work keeps running in the main process; only the quit stops waiting for it. For a session profile save that matters: takeSession waits for the guest to power off and then calls runner.start(cfg) to boot it again. With the power button pressed mid-hibernate, the guest powers off (a plain shutdown reads as 'guest' too, see #120), waitForExit here returns true, and at about the same time the save snapshots the disk and starts the VM again. Then host.quit() runs and before-quit calls killAll(), so a guest that is just booting gets a hard power off. Before this PR the quit waited for the save, so that couldn't happen.
The save shouldn't be able to start the VM again once the quit has given up on it. Something like a per-VM hold on start that the quit sets for the abandoned VMs (and lifts if the user cancels the Force off question) would do it.
| noLink: true | ||
| }) | ||
| if (choice === NOW) return true | ||
| if (choice === NOW) return this.workingNames() |
There was a problem hiding this comment.
workingNames() reads the work at the moment of the click, not the work the question listed. If another VM starts a profile save or disk work while the question is open, it gets counted as abandoned even though the message never named it. Using the VMs from work (the list the question showed) keeps the answer to what the user was asked about.
A session profile save boots the guest again once it has hibernated. If the app is quitting and no longer waits for that save, the boot only leads to a hard power off from killAll a moment later. holdStarts makes start() refuse that VM until it is let go.
…d about Quit anyway and Quit now hold starts for the VMs whose work is left unfinished, and let go of them if the quit doesn't happen after all (Cancel, keeping the VMs in the tray, or Cancel in the Force off question). Quit anyway now only counts the VMs the question named. Work that starts on another VM while the question is open is still waited for.
|
Both findings were right.
Checked with: 5 more quitFlow tests (hold set, released on the three stay paths, only the named VMs), a new |
A21-devs
left a comment
There was a problem hiding this comment.
Went through the two follow-up commits against the first review.
- Restarted save: fixed.
abandon()holds starts for the abandoned VMs,start()checks the hold before anything else, and every path that ends with the app staying lets go (lines 141, 151 and 297). The no-VMs-running path quits with the hold still set, which is fine since nothing is left to start. - Only the listed work: fixed,
abandon(new Set(work.map(([n]) => n)))uses the question's own list, and the kali test covers it.
One note below, not something to fix here.
| }) | ||
| ) | ||
| if (!(await this.waitForShutdown(names))) return | ||
| if (!(await this.waitForShutdown(names))) return this.release(abandoned) |
There was a problem hiding this comment.
Letting go here is right, but by the time the Force off question gets its Cancel (at least a minute in), the abandoned save has usually already reached its start() and failed on the hold. So after Cancel the VM stays off and the save reports an error, even though the app didn't quit. That is the same "Cancel after the guests were already told to shut down" situation as #158, so it fits better there than in this PR.
Closes #155
After Quit anyway (or Quit now in the tray while waiting for the work), the work is left unfinished, but if the VM doing it was also running, Shut down VMs and quit still waited for that work before pressing the VM's power button. With a profile save going that can be minutes, and the app sat in the tray saying it was shutting down.
How:
workFirstnow returns the set of VMs whose work was abandoned instead oftrue: everything still working when Quit anyway was clicked, or still working when Quit now was picked in the tray. Waiting until it finished gives an empty set.askAndQuittoshutDownAllAndQuit. For those VMs the power button is pressed right away, with noworkDoneand no wait for the guest agent after a save.pressPowerso both paths use it.For an abandoned profile save the power button can arrive while the guest hibernates and turn it into a plain shutdown. That's what Quit anyway already says ("no profile is made and the VM is not started again"), so I think it's the right trade.
Testing
tests/quitFlow.test.ts: tray Quit then Quit anyway, window close with the quit close behavior, work starting on another VM after the question still being waited for, and tray Quit now. All four fail on main (two by timing out in the wait).npm run typecheck,npm test(184 pass),npm run build