lsongdev / lsongdev/node-escpos
node-escpos prints twice
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 443
- PR merge metrics
- No merged PRs in 30d
Description
I have the following code
```
const escpos = require('escpos');
escpos.USB = require('escpos-usb');
const device = new escpos.USB(2727, 772);
const options = { encoding: "ISO8859-15" /* default */ }
const printer = new escpos.Printer(device, options);
device.open(function(error){
console.log("internal call")
printer
.text("Test123 This is a happy printer doing it's job twice. Too happy?")
.close()
});
```
when I run the code with
`$node index.js`
the thermal printer will print the text twice. I have also tried to add the `cut()` `flush()` method within the open callback method. I can see that this callback method is called two times, as in the console it prints "internal call" twice.
Expected: the printer only prints the text once.
Thanks for the help
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with index.js and the device.open callback shown in the report, then run node index.js while observing the callback log and printer output. Trace why the callback is entered twice and verify that the callback and text are each processed only once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100