Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use setImmediate with callback in _close() #111

Merged
merged 1 commit into from
May 27, 2018
Merged

Conversation

ralphtheninja
Copy link
Member

Closes #109

@vweevers
Copy link
Member

Breaks the destroy tests.

@ralphtheninja ralphtheninja mentioned this pull request May 26, 2018
@vweevers
Copy link
Member

vweevers commented May 27, 2018

Breaks the destroy tests.

I suspect that has something to with deferred-leveldown. When the db (a levelup instance) has closed, db.db points to an instance of deferred-leveldown instead of level-js.

https:/Level/level.js/blob/fb185a978aaee2f5b0d5b106838a4ea1798873e1/test/custom-test.js#L125

@vweevers
Copy link
Member

vweevers commented May 27, 2018

Confirmed. We have a few options:

  1. Remove the ability to destroy(db). User must do destroy(location[, prefix]). I prefer this.
  2. Require the user to do destroy(db._db) (where db is levelup, and db._db is level-js)
  3. Require the user to keep a reference to the level-js db themselves so that they can do destroy(db)
  4. Hack: find the level-js instance: if (!db.prefix && db._db) db = db._db (where db is either level-js, deferred-leveldown or levelup).

@ralphtheninja
Copy link
Member Author

Yes I just found the same problem. Since we do setImmediate() then db.db is DeferredLevelDOWN object. I wouldn't mind picking option 1 either.

@vweevers
Copy link
Member

I wouldn't mind picking option 1 either.

Let's go with that 👍

@ralphtheninja
Copy link
Member Author

I'll keep this PR open and fix that first.

@ralphtheninja ralphtheninja merged commit a54fdde into master May 27, 2018
@ralphtheninja ralphtheninja deleted the sync-cb-in-close branch May 27, 2018 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants