With levelup, it is possible to use database objects before they are fully open. If a method that needs an open database is called, the call is deferred until the open operation is complete. Also, if the open method is called while the database is being opened, it will wait for the running open operation to complete instead of initiating a new one.
If the open operation fails, a user would expect all the deferred operations to fail as well. However, this is not what happens. Instead, error event is fired (which is not fired for any other errors), and the deferred calls never finish: callbacks are never called, promises are never settled.
I think that if open operation fails, database should enter an error state in which all pending and future calls immediately fail with an error. While in the current code it is possible to attempt to reopen a database after an error, this is rarely what the user wants. In the current code, if a method is called after a failed attempt to open the database, it will be deferred in anticipation that the user will try to open the database again. In asynchronous code, it is easy to call a method after the open operation fails but before the failure is processed by the user code. In this case, if the user code doesn't attempt to reopen the database, these calls will hang.
With
levelup, it is possible to use database objects before they are fully open. If a method that needs an open database is called, the call is deferred until the open operation is complete. Also, if theopenmethod is called while the database is being opened, it will wait for the running open operation to complete instead of initiating a new one.If the open operation fails, a user would expect all the deferred operations to fail as well. However, this is not what happens. Instead,
errorevent is fired (which is not fired for any other errors), and the deferred calls never finish: callbacks are never called, promises are never settled.I think that if open operation fails, database should enter an error state in which all pending and future calls immediately fail with an error. While in the current code it is possible to attempt to reopen a database after an error, this is rarely what the user wants. In the current code, if a method is called after a failed attempt to open the database, it will be deferred in anticipation that the user will try to open the database again. In asynchronous code, it is easy to call a method after the open operation fails but before the failure is processed by the user code. In this case, if the user code doesn't attempt to reopen the database, these calls will hang.