Urgent.News

What's breaking now, across thousands of outlets.

Tech

Three things that bit us moving a document scanner fully into the browser

Photographing a page and turning it into a clean, printable PDF is, on paper, a solved problem: read a file, fix the perspective on a canvas, flatten the shading, write a PDF. Browsers have shipped every primitive for that for years, and none of it needs a server. I work on LensUp , which does exactly that — the whole pipeline runs in the tab, and files are never uploaded. Disclosure up front:…

1. Web Share API can become unavailable

When generating a multi-page PDF from full-resolution photos on a mid-range phone, the process may take too long for the transient user activation required by the Web Share API to still be active by the time the file is ready. This results in a "NotAllowedError," and the share sheet never opens. This failure is more likely to occur on slow devices.

To mitigate this issue, the workflow can be decoupled, with the PDF preparation happening first and then checking whether the user's activation is still present before attempting to share. If the activation has expired, a toast message can inform the user to tap share again.

2. Feature-detect the file sharing option

When sharing the generated PDF, it is crucial to check whether the device supports sharing files. The navigator object's `canShare` property indicates whether the device supports file sharing, but it does not specify whether the specific `application/pdf` file type is supported. Therefore, a separate probe is needed to build a real File object with the PDF MIME type `%PDF` and test if it can be shared.

If the device does not support sharing files of the intended type, the share button can be hidden to avoid confusion or errors.

3. AbortError is a normal outcome

When the user dismisses the share sheet without selecting an action, the `navigator.share()` method will throw an `AbortError`. This error is expected and should not be considered an indication of a failure. Instead of displaying a toast message or presenting it as a failure, the `AbortError` should be caught and handled appropriately, as it signifies that the user decided to cancel the share operation.

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

Second brain ที่ไม่ใช้ vector DB, บทเรียน 736 ดาวจาก PM Brain

Second brain ที่ไม่ใช้ vector DB, บทเรียน 736 ดาวจาก PM Brain โดย Nokka (นก-กา) | 12 กันยายน 2026 บทความนี้เขียนโดย AI (deepseek-v4.1-flash) ผ่าน Hermes Agent ตรวจสอบและเรียบเรียงโดย Nokka เมื่อวานนี้…

Ecualizador de Audio online

Hola buen día me gustaría compartir este pequeño proyecto con todos la verdad es que no soy profesional pero me gustaría implementar mejoras espero y me puedan ayudar con eso muchas gracias…

Distributed Locks

One-liner: A distributed lock ensures that only one node in a cluster can perform a critical operation at a time — preventing race conditions across services. ❓ Why Do You Need Distributed Locks?

More from Sunday 13 September →