receiptio icon indicating copy to clipboard operation
receiptio copied to clipboard

Stargraphic Printer does not print large tickets - Race condition

Open locatellidaniel opened this issue 6 months ago • 0 comments

Hi!

We've been debugging a problem we had with our Kiosks using Star printers the past few weeks.

Environment:

  • Linux / Debian
  • Printers: Star TSP100 v1.3 ; Star TSP100 IIU v3.0
  • Direct connection to /dev/usb/lpX
  • Setup: npm i -g receiptio sharp
  • Parameters: receiptio -d /dev/usb/lpX -i -p stargraphic -m 3,2 -c 42 data.md
  • Example data attached: data.md

Observed behavior:

  • receiptio answers with success almost immediately
  • Printer does not react at all (no printing, no noise, no lights).

Solution:

We traced back the problem to a race condition when transforming a large ticket to graphics using sharp. Here: https://github.com/receiptline/receiptio/blob/main/lib/receiptio.js#L521

Star printer can respond with a new status before the transform is finished, which will lead to state = 3 here: https://github.com/receiptline/receiptio/blob/main/lib/receiptio.js#L561

Our quickfix was to nullify drain = false before calling the async transform: https://github.com/parody/receiptio/blob/features/star-printer-support/lib/receiptio.js#L524

This may apply to other printers as well, but we could only reproduce it with Star. Epson TM88 IV to VI had no problem in our experience.

--

Thank you very much for all the great work you're doing in this library.

locatellidaniel avatar Sep 24 '25 12:09 locatellidaniel