Skip to content

Commit 51f7750

Browse files
authored
close print window before freeing mem (#146)
Avoid zombies when printing in silent mode
1 parent c0f5bf2 commit 51f7750

File tree

1 file changed

+11
-2
lines changed
  • resources/js/electron-plugin/src/server/api

1 file changed

+11
-2
lines changed

resources/js/electron-plugin/src/server/api/system.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,18 @@ router.post('/print', async (req, res) => {
7171
silent: true,
7272
deviceName: printer,
7373
}, (success, errorType) => {
74-
res.sendStatus(200);
74+
if (success) {
75+
console.log('Print job completed successfully.');
76+
res.sendStatus(200);
77+
} else {
78+
console.error('Print job failed:', errorType);
79+
res.sendStatus(500);
80+
}
81+
if (printWindow) {
82+
printWindow.close(); // Close the window and the process
83+
printWindow = null; // Free memory
84+
}
7585
});
76-
printWindow = null;
7786
});
7887

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

0 commit comments

Comments
 (0)