levelup constructor without callback causes unhandled rejection
See original GitHub issueUsing v4.0.1 of levelup
and leveldown
. The following command causes an unhandled rejection:
levelup(leveldown('/path/to/nonexistent/file'))
UnhandledPromiseRejectionWarning: OpenError: IO error: /path/to/nonexistent/file: No such file or directory
....
at (node:69500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
This happens because the final line in the LevelUP
constructor, this.open(callback)
, is a floating promise.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Handling Errors in JavaScript: The Definitive Guide
Now the Error instance alone does not cause anything. ... Unhandled promise rejection (rejection id: 1): Error: something went wrong
Read more >What is an unhandled promise rejection? - Stack Overflow
In my case was Promise with no reject neither resolve, because my Promise function threw an exception. This mistake cause UnhandledPromiseRejectionWarning ...
Read more >The way JavaScript ES8 made me to STOP writing call back ...
Even worse, there's no error checking, so any of the callbacks could fail silently as an unhandled promise rejection. Promise Chain. Let's make...
Read more >Developing Async Sense in JavaScript — Part III: Promises
We instantiate the Promise constructor and give it a callback ... A Promise makes no assumptions on how or where we'll process its...
Read more >JavaScript Promise Guides - DEV Community
How to rewrite a callback function in Promise form and async/await form in ... I get the error: UnhandledPromiseRejectionWarning: TypeError: Cannot read ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aye. The unhandled rejection is somewhat consistent with the previous behavior of emitting an error event, but the difference is you can’t catch it now. Perhaps we should change this line:
https://github.com/Level/levelup/blob/c56f863e41f1b00216837963be34d4ba74458b19/lib/levelup.js#L57
To:
Fixed in 4.3.1