question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fileOpen() function doesn't reject promise when user dismiss file picker prompt without selecting a file

See original GitHub issue

The API works fine when selecting files and also handles rejection when the chosen file is not valid, but when the user dismiss the file picker prompt without selecting any file, execution gets stuck in await fileOpen().

Code sample:

let fileHandle;
try {
   fileHandle = await fileOpen({
     mimeTypes: ['text/csv'],
     extensions: ['.csv'],
   });
} catch(error) {
   console.log(error); // Nothing happens here
}

AC: Reject promise in fileOpen function when file picker prompt is dismissed

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tomayaccommented, Feb 26, 2021

Safari Web Inspector:

Screen Shot 2021-02-26 at 17 47 19
1reaction
tomayaccommented, Feb 26, 2021

@mikeAtHexosIp Thanks again for reporting this. I have just release v0.14.0 that includes this fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cancel event on input type="file" - javascript - Stack Overflow
Scenario 1 : When the select file is clicked and then cancel is clicked ... prompted the dialog to close */ event: Event...
Read more >
Window.showOpenFilePicker() - Web APIs - MDN Web Docs
An AbortError is thrown if a user dismisses the prompt without making a selection or if a file selected is deemed too sensitive...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
Here's an example: new Promise((resolve, reject) => { resolve("ok"); }). then((result) => { throw new Error("Whoops!"); // rejects the promise ...
Read more >
How To Use Multithreading in Node.js - DigitalOcean
Node.js runs JavaScript code in a single thread, which means your code can do one task at a time and can't use multiple...
Read more >
Node.js v19.3.0 Documentation
If the function does not return a promise, assert.doesNotReject() will return a rejected Promise with an ERR_INVALID_RETURN_VALUE error. In both cases the error ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found