4

My code is similar to many examples on the web, including MDN code at https://mdn.github.io/dom-examples/web-share/

      btn.addEventListener('click', () => {
        navigator.share(shareData)
          .then(() =>
            console.log('MDN shared successfully');
          )
          .catch((e) =>
            console.error('Error: ' + e);
          )
      });

Issue:

navigator.share returns a promise supposed to fail if sharing is denied. In my case it does so, but after several seconds of delay. My main problem is this delay: I can fallback if I know sharing API is failing, except here I need to wait for an unknown amount of time before the error.

Mode details:

  • The error is "Error: AbortError: Share canceled"
  • I did not cancel anything (I see no UI before the error happens). Maybe Windows denied something without displaying any message.
  • I am using Windows 8.1 Pro, this could be related.
  • Same problem for me with Chrome 90.0.4430.93 (and previous version 89.0.4389.128), but also with Edge (89.0.774.54 Official build 64-bit)
  • delay is longer than 20 seconds (disconnecting internet access does not change that)
kubicle
  • 73
  • 10

1 Answers1

1

I just tried the demo on Windows 10 on both Chrome and Edge (Stable), and it worked. Maybe an extension is interfering with the API?

MDN demo showing Web Share in action

DenverCoder9
  • 2,024
  • 11
  • 32
  • 1
    Right. Thanks, it helps: looks like "something outside Chromium". But probably not an extension since I just found out Edge is having the same problem on my machine. I will edit my question too. A bit sad if this just becomes a "Win 8.1" does it wrong, but well... – kubicle May 05 '21 at 07:45
  • 1
    Any idea about which browser settings can interfere is welcome. I disabled extensions and allowed "pop-ups", just in case; no improvement from that. BTW @DenverCoder9, I tried to "vote up" your answer but cannot since I don't have the "reputation" to do it (even for my own question, sigh...) – kubicle May 05 '21 at 07:56
  • 3
    Using BrowserStack and Edge 90 on Windows 8.1, I could indeed confirm the behavior you describe in your post. Seems like a Windows issue then. FWIW, I checked Edge 90's native system menu on Windows 8.1 and Windows 10, and on 8.1 it lacks the Share option. Compare [Windows 8.1](https://snipboard.io/NQw4lg.jpg) to [Windows 10](https://snipboard.io/qkWZC1.jpg). – DenverCoder9 May 06 '21 at 08:32
  • 1
    You are right; looks like Windows 8.1 has been left behind... Thank you for detailed investigation! – kubicle May 08 '21 at 14:01
  • On windows 11, the windows open, load but close after 1 or 2 seconds, any idea ? – neoteknic Feb 28 '23 at 17:25