Skip to content

High latency in printer.connect() on v4.4.4+ (7–8s delay) while v4.3.3 is fast but has 16KB limitation #243

@IzoJay

Description

@IzoJay

I am experiencing a significant connection latency regression in react-native-esc-pos-printer starting from version v4.4.4 and continuing in the latest v4.5.0.

Summary

v4.3.3 and below
await printer.connect() completes in less than 1 second
Printing is fast and works reliably
However, these versions have a 16 KB buffer/data limitation on Android, which causes issues for larger print jobs and also creates Android publishing / policy-related constraints, making them unsuitable for production Android builds

v4.4.4 and above (including v4.5.0)
The 16 KB Android data limitation appears to be resolved
But await printer.connect() consistently takes 6–8 seconds
This delay happens before any actual print command is executed
The latency is high enough to noticeably impact POS user experience

Impact

In a POS environment, a 6–8 second delay during printer connection is not acceptable, especially when printing receipts frequently.
At the moment, developers are forced to choose between:
Fast connection (≤ v4.3.3) with 16 KB Android data and publishing limitations, or
Correct Android-compatible data handling (≥ v4.4.4) with severe connection latency

Expectation

Ideally:
Connection time should remain close to v4.3.3 performance (less than 1 second)
While retaining the fixes introduced in v4.4.4 and above for Android-safe larger data handling

Demo component (used in a fresh app):

const printer = new Printer({
  target: printerData.target,
  deviceName: printerData.deviceName,
});

await printer.addQueueTask(async () => {
  logTime(3);
  await printer.connect(); // latency occurs here
  logTime(4);

  await printer.addTextAlign(PrinterConstants.ALIGN_CENTER);
  await printer.addText('PRINT DEMO\n');
  await printer.addCut(PrinterConstants.CUT_FEED);

  const result = await printer.sendData();
  await printer.disconnect();
  return result;
});

Steps to reproduce

  1. Install react-native-esc-pos-printer v4.4.4 or later (issue also reproducible on v4.5.0).
  2. Set up a reachable ESC/POS TCP printer on a local network.
  3. Use the demo code provided in the description (no retries, no tryToConnectUntil).
  4. Launch the app on a real device (Android or iOS).
  5. Start printer discovery using usePrintersDiscovery.
  6. Select a discovered printer and trigger print.
  7. Observe the console logs.
  8. logTime(3) is printed immediately.
  9. logTime(4) appears 6–8 seconds later.
  10. Note that no print commands are executed during this delay; it occurs only during await printer.connect().
  11. Comparison step (optional but confirming)
  12. Downgrade the library to v4.3.3.
  13. Repeat steps 3–8.
  14. Observe that printer.connect() completes in less than 1 second, but large print jobs fail due to the 16 KB Android limitation and publishing constraints.
  15. react-native-esc-pos-printer version

4.5.0

React Native version

0.82.1

Platforms

Android, iOS

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions