Repository navigation
Conversation
Web NFC allows one pending push per document. writeNFC() built a fresh NDEFReader and called write() on every button press, so: press 1 starts a push and waits for a tag nothing visibly happens, so the user presses again press 2 aborts press 1 press 1's promise rejects with "AbortError: push is canceled due to a new push request" -- and that rejection is what fills the message box The UI says the write failed while press 2 is still live and usually about to succeed, so the user keeps pressing and the tag often does get written without ever being reported. Keep one reusable NDEFReader and one in-flight write. A second press is now an explicit AbortController cancel rather than a competing push, and AbortError is reported as cancelled rather than failed. The button shows Cancel while a write is pending so the state is visible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Writing a tag reports failure even when the write succeeds. The message is:
Web NFC allows exactly one pending push per document.
writeNFC()(
templates/write_tag.html:45) builds a freshNDEFReaderand callswrite()onevery button press:
write()aborts the first, and the first promise rejects withAbortError.the second push is usually still live and about to succeed.
The tag frequently does get written; the UI just never says so.
This is client-side only and unrelated to cloud vs LAN — it affects any Android
Chrome user.
Fix
One reusable
NDEFReader, one in-flight write tracked inpendingWrite, and asecond press becomes an explicit
AbortControllercancel rather than a competingpush.
AbortErroris reported as "cancelled", not "failed". The button doubles asCancel while a write is pending, so the state is visible.
Full diff in the PR; the shape is:
Testing
Running in production since 2026-08-30, verified by hand on a Pixel with Chrome
over https: first press waits, tapping the tag writes and now reports success;
pressing again mid-wait reports "cancelled" instead of "failed" and leaves the
reader reusable for the next attempt.
Web NFC needs a secure context, so this is untestable over a plain-http LAN URL —
that path is unchanged (
'NDEFReader' in windowis false and the existingunsupported-browser message shows).