Skip to content

Commit

Permalink
close print window before freeing mem (#146)
Browse files Browse the repository at this point in the history
Avoid zombies when printing in silent mode
  • Loading branch information
labomatik authored Dec 26, 2024
1 parent c0f5bf2 commit 51f7750
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions resources/js/electron-plugin/src/server/api/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,18 @@ router.post('/print', async (req, res) => {
silent: true,
deviceName: printer,
}, (success, errorType) => {
res.sendStatus(200);
if (success) {
console.log('Print job completed successfully.');
res.sendStatus(200);
} else {
console.error('Print job failed:', errorType);
res.sendStatus(500);
}
if (printWindow) {
printWindow.close(); // Close the window and the process
printWindow = null; // Free memory
}
});
printWindow = null;
});

await printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`);
Expand Down

0 comments on commit 51f7750

Please sign in to comment.