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

Error when destroying a db after dumping its contents #61

Open
monsterlane opened this issue Mar 27, 2017 · 1 comment
Open

Error when destroying a db after dumping its contents #61

monsterlane opened this issue Mar 27, 2017 · 1 comment

Comments

@monsterlane
Copy link

monsterlane commented Mar 27, 2017

var stream = new MemoryStream();
var dumpedString = '';

stream.on('data', function(chunk) {
	dumpedString += chunk.toString();
});

temp_db.dump(stream).then(function () {
	console.log('Yay, I have a dumpedString: ' + dumpedString);
}).then(function() {
	return temp_db.destroy();
}).catch(function (err) {
	console.log('oh no an error', err);
});

In the browser console I see this:

pouchdb:api tempdb +67ms destroy
pouchdb:api tempdb +1ms get _local/_pouch_dependentDbs Object { } vendor.js:80884:8
17:42:31.137 pouchdb:api tempdb +3ms get error Object { status: 404, name: "not_found", message: "missing", error: true, stack: "" }
TypeError: destructListeners.get(...) is undefined [Learn More]

Do I have to unbind something before I destroy the db? I'm using your example code inside an Ember project (desktop web browser).

@stickbyatlas
Copy link

Since I was collaborating on the code above, just thought I'd add some additional observations and context. We were trying to dump the database from inside PouchDB's complete event handler, which I suspect was creating some kind of chicken-and-egg issue. Once we moved temp_db.destroy() to an external function (Ember's route's willTransition hook), the error stopped happening.

I'm curious about the actual mechanics of why you can't destroy the database from inside the complete handler. It kind of makes sense intuitively, but if that's the case, then how are you supposed to destroy a database immediately after a replication? setTimeout an anonymous function from inside the complete handler?

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

No branches or pull requests

2 participants