Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Use setImmediate with callback in _close() #111

Merged
merged 1 commit into from
May 27, 2018
Merged

Conversation

ralphtheninja
Copy link
Member

Closes #109

@ralphtheninja ralphtheninja requested a review from vweevers May 26, 2018 20:03
@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://github.com/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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants