Urgent.News

What's breaking now, across thousands of outlets.

Tech

What happens when an offline POS sale syncs twice?

A cashier completes a sale while the connection is down. Later, the server saves it, but the response never reaches the device. The app retries. Without a way to recognize the original request, the second attempt can create a second receipt and deduct stock again. Give each sale a stable ID Generate a client sale ID when checkout starts. Save it with the completed sale and the pending sync entry…

When a Point of Sale (POS) transaction is completed while the internet connection is unavailable, there is a risk that the sale may be processed twice. The first sale is saved on the server, but the response is never received by the device. The app then retries the transaction, unaware that the previous attempt already occurred. This can result in two receipts being generated and inventory being deducted twice.

To prevent this issue, it is crucial to assign a unique client sale ID when checkout begins. This ID should be saved with the completed sale and the pending sync entry in a single local transaction. The same ID should be maintained throughout retries and app restarts. The server should also be able to handle retries safely by using a unique database constraint that is specific to the store and client sale ID.

When the sale and its stock movements are committed together, the system can ensure that the same ID arriving with the same payload will display the existing receipt. If the payload differs, a conflict is returned, allowing the app to review the discrepancy.

It is essential to thoroughly test the lost acknowledgement feature. To complete a sale offline, the device should be disconnected, and the server should commit the transaction. Then, simulate a dropped response by disconnecting the device again. Restart the app and retry the pending sale. Verify that the receipt number remains unchanged, and inventory is moved exactly once. In the event of a timeout, treat it as an unknown outcome and handle it accordingly.

By implementing a stable ID system and ensuring that the server and client can handle retries reliably, retailers can avoid the complications of duplicate POS sales when offline. This approach not only simplifies the recovery process for customers but also maintains accurate inventory levels throughout the sales process.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

NestJS vs Express.js: Choosing the Right Framework for Your Next Node.js Project

Node.js is used by 48.7% of developers in the Stack Overflow Developer Survey 2025. Inside that group, Express.js is used by 19.9% of respondents and NestJS by 6.7%.

  • 48.7% of developers used Node.js in 2025 Stack Overflow survey
  • NestJS has 6.7% adoption, growing due to structured approach
  • Express.js excels in speed and control, while NestJS offers structure and features

5 Security Mistakes I See in Flask + React Apps (and How to Fix Them)

Flask and React are a great pairing: fast to build, flexible, and easy to deploy. But that same speed means security often gets pushed to "later," and later usually means after something breaks.

  • Validate user input against schema using Pydantic
  • Store JWTs in HttpOnly, Secure, SameSite cookies
  • Include token in Authorization header on React frontend

How do you tune speculative decoding in a production serving stack?

Tune speculative decoding against your own traffic, not a benchmark. Choose a method that fits your workload, set draft length from measured acceptance rate, and re-test at production concurrency…

  • Base speculative decoding method on your own traffic data, not benchmarks.
  • Choose n-gram or suffix decoding for modest speedup; use EAGLE or MTP for best latency reduction.
  • Adjust draft length based on acceptance rate; test multiple values and monitor per-request metrics.

Running untrusted pull request code from agents and contributors

Originally published on sandscale.dev . A pull request is a request to run someone else's code on your machine. CI has always worked this way: check out the branch, install dependencies, run the…

  • Pull requests run untrusted code, posing risks like code escaping or data exfiltration
  • Sandscale's sandbox creates a separate kernel and network environment for each PR
  • After tests, sandbox should be stopped and discarded to prevent lingering malicious code

More from Friday 20 November →