You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows] USB thermal printers cannot reliably print raw ESC/POS receipts #206
Windows USB thermal printers do not reliably print receipts or kitchen order tickets through the desktop app.
Reproduction
Run FloCafe on Windows.
Install/configure a USB thermal printer through Windows.
Add it in FloCafe under Settings → Receipts & Printers.
Set it as the default printer.
Use Test Print, complete a sale, or print a KOT.
Actual behavior
The Windows USB print path fails before sending raw ESC/POS data.
The current implementation creates node-thermal-printer with a printer:<name> interface but does not provide the required printer driver. With the current node-thermal-printer version, this produces:
No driver set!
The fallback uses PowerShell PrintTo against a .bin file, which is not a reliable raw ESC/POS printing mechanism.
Expected behavior
The app should send the generated ESC/POS bytes directly to the configured Windows printer and successfully print:
Test pages
Receipts
Kitchen order tickets
58mm and 80mm layouts
If the printer is unavailable, the app should report a clear failure without claiming that printing succeeded.
Root cause
The affected code is:
main/printers/thermal.ts
printViaUSBWindows()
The node-thermal-printer system-printer interface requires a printer driver, but the current code does not pass one.
Verification required
The fix needs real Windows hardware testing. Please verify with at least one USB thermal printer, preferably including Epson, Xprinter, or Rugtek hardware:
Test Print
Normal receipt printing
KOT printing
58mm and 80mm paper
Printer disconnected
Printer reconnected
Printer configured through auto-detection and manual configuration
The native Winspool/raw-printing approach should be validated on Windows before considering this fixed. Linux/macOS printer tests do not validate this path.
Fixed on main in fe65926 (Windows) and d1a4b71 (CUPS parity). Leaving this open — the Windows path still needs hardware validation, checklist below.
Root cause
Confirmed as reported. printViaUSBWindows() built a node-thermal-printer instance with a printer:<name> interface but passed no driver, so it threw No driver set! before any bytes were sent. The fallback used PowerShell Start-Process -Verb PrintTo, which hands the file to the print driver rather than writing raw bytes — and reported success whether or not anything printed.
Fix
Write to the Windows spooler with datatype RAW (OpenPrinter → StartDocPrinter → StartPagePrinter → WritePrinter), the documented way to get bytes past the driver untouched. Implemented as C# compiled at run time by Add-Type, so the app stays free of per-Electron-ABI native prebuilds.
Pre-flight GetPrinter status check.OpenPrinter succeeds against the queue even when the device is unplugged, so without this a disconnected printer silently spools and reports success — the exact behaviour this issue asks to eliminate.
-EncodedCommand instead of a .ps1 file. A GPO-set ExecutionPolicy silently overrides -ExecutionPolicy Bypass, so a script file would have failed on precisely the managed machines a POS runs on.
Printer name and payload path passed through the child environment, never interpolated into script text.
%TEMP% instead of C:\Windows\Temp, which a standard user cannot write to.
Async, with a timeout and windowsHide — printing no longer blocks the Electron main process or the Express API, and no console window flashes on each receipt.
node-thermal-printer is dropped; that call site was its only consumer.
Verified before hardware
The exact embedded C# compiles at LangVersion 5 (what PowerShell 5.1's CodeDom accepts) with 0 warnings and 0 errors.
The full pipeline runs under pwsh: the here-string embedding survives, Add-Type compiles it, and SendRaw is genuinely reached — failing only at the winspool.drv P/Invoke, which exists only on Windows.
Injection probe: a printer name of '; Write-Output PWNED; # is treated as data, not script.
Every failure path exits non-zero and returns false. No path reports success without having written bytes.
Build clean, no new lint, 106 printing-related tests pass.
Still needs real hardware
None of the above proves bytes reach paper. Please run:
Test Print
Receipt on a completed sale
KOT
58mm and 80mm
Printer disconnected — must report failure, not success
Printer reconnected
Auto-detected and manually configured printers
Two log lines tell the story:
[Printer] Windows raw print accepted for "<name>" (FLO_JOB_ID=<n>)
[Printer] Windows raw print failed for "<name>": <reason>
A FLO_JOB_ID means the spooler accepted the bytes. If that appears but no paper comes out, the problem is downstream — please attach the printer's driver name and port from Windows print settings.
Known weak spot: the disconnected-printer case depends on the driver populating GetPrinter status flags. Plenty of low-cost thermal drivers report Status=0 even when unplugged; the check then degrades to a no-op and that bullet may still fail. This is the one I would expect to need a second pass.
Known gap: printers installed as a USB virtual COM port rather than as a Windows print queue will not work — there is no queue for OpenPrinter to open. Those do not appear in wmic printer detection either, so they fail at discovery first.
Related
d1a4b71 fixes the same false-success class on macOS and Linux, which were never covered by this issue but had the identical flaw: lp exits 0 as soon as CUPS accepts a job, so a disabled queue — which is what CUPS does after a backend failure, e.g. an unplugged printer — was also reported as a successful print. Now pre-flighted with lpstat, run under LC_ALL=C since that output is localised.
Worth stating plainly for both platforms: a spooler can only confirm it accepted the bytes, never that paper emerged. The first print immediately after a disconnect may still report success on Windows and CUPS alike, because the queue is only marked bad once a job has actually failed.
The Windows USB path now sends raw ESC/POS bytes through Winspool instead of relying on node-thermal-printer without a driver or the unreliable PowerShell PrintTo fallback. It includes Unicode-safe printer names, printer pre-flight checks, timeout/error handling, and reports a FLO_JOB_ID only after the spooler accepts the raw job. Test Print, receipts, and KOTs now use the same corrected path, and failures are surfaced instead of reported as success.
The remaining hardware checklist (Epson/Xprinter/Rugtek, 58/80mm, disconnect/reconnect, auto-detected/manual queues) should be covered as release validation, but the implementation defect described here is fixed. Closing issue 206.
Activity
fix(printers): send raw ESC/POS via winspool on Windows
fix(printers): fail loudly when the CUPS queue cannot print
itsbkm commentedon Aug 1, 2026
Fixed on
mainin fe65926 (Windows) and d1a4b71 (CUPS parity). Leaving this open — the Windows path still needs hardware validation, checklist below.Root cause
Confirmed as reported.
printViaUSBWindows()built anode-thermal-printerinstance with aprinter:<name>interface but passed no driver, so it threwNo driver set!before any bytes were sent. The fallback used PowerShellStart-Process -Verb PrintTo, which hands the file to the print driver rather than writing raw bytes — and reported success whether or not anything printed.Fix
Write to the Windows spooler with datatype
RAW(OpenPrinter→StartDocPrinter→StartPagePrinter→WritePrinter), the documented way to get bytes past the driver untouched. Implemented as C# compiled at run time byAdd-Type, so the app stays free of per-Electron-ABI native prebuilds.Also addressed along the way:
OpenPrinterW/StartDocPrinterW) so non-ASCII printer names survive marshalling.GetPrinterstatus check.OpenPrintersucceeds against the queue even when the device is unplugged, so without this a disconnected printer silently spools and reports success — the exact behaviour this issue asks to eliminate.-EncodedCommandinstead of a.ps1file. A GPO-set ExecutionPolicy silently overrides-ExecutionPolicy Bypass, so a script file would have failed on precisely the managed machines a POS runs on.%TEMP%instead ofC:\Windows\Temp, which a standard user cannot write to.windowsHide— printing no longer blocks the Electron main process or the Express API, and no console window flashes on each receipt.node-thermal-printeris dropped; that call site was its only consumer.Verified before hardware
LangVersion 5(what PowerShell 5.1's CodeDom accepts) with 0 warnings and 0 errors.pwsh: the here-string embedding survives,Add-Typecompiles it, andSendRawis genuinely reached — failing only at thewinspool.drvP/Invoke, which exists only on Windows.'; Write-Output PWNED; #is treated as data, not script.false. No path reports success without having written bytes.Still needs real hardware
None of the above proves bytes reach paper. Please run:
Two log lines tell the story:
A
FLO_JOB_IDmeans the spooler accepted the bytes. If that appears but no paper comes out, the problem is downstream — please attach the printer's driver name and port from Windows print settings.Known weak spot: the disconnected-printer case depends on the driver populating
GetPrinterstatus flags. Plenty of low-cost thermal drivers reportStatus=0even when unplugged; the check then degrades to a no-op and that bullet may still fail. This is the one I would expect to need a second pass.Known gap: printers installed as a USB virtual COM port rather than as a Windows print queue will not work — there is no queue for
OpenPrinterto open. Those do not appear inwmic printerdetection either, so they fail at discovery first.Related
d1a4b71 fixes the same false-success class on macOS and Linux, which were never covered by this issue but had the identical flaw:
lpexits 0 as soon as CUPS accepts a job, so a disabled queue — which is what CUPS does after a backend failure, e.g. an unplugged printer — was also reported as a successful print. Now pre-flighted withlpstat, run underLC_ALL=Csince that output is localised.Worth stating plainly for both platforms: a spooler can only confirm it accepted the bytes, never that paper emerged. The first print immediately after a disconnect may still report success on Windows and CUPS alike, because the queue is only marked bad once a job has actually failed.
docs: add printer troubleshooting section to README
itsbkm commentedon Aug 4, 2026
Resolved in the v2.7.0 release.
The Windows USB path now sends raw ESC/POS bytes through Winspool instead of relying on node-thermal-printer without a driver or the unreliable PowerShell PrintTo fallback. It includes Unicode-safe printer names, printer pre-flight checks, timeout/error handling, and reports a FLO_JOB_ID only after the spooler accepts the raw job. Test Print, receipts, and KOTs now use the same corrected path, and failures are surfaced instead of reported as success.
The remaining hardware checklist (Epson/Xprinter/Rugtek, 58/80mm, disconnect/reconnect, auto-detected/manual queues) should be covered as release validation, but the implementation defect described here is fixed. Closing issue 206.