Closed mikeymckay closed 9 years ago
first off get the stack trace, that will be the .stack property of the error object
Yeah, it's a bit of a nightmare because it is browserified and the source map isn't working, so I can click through and see the lines that are causing the error, but they don't refer to line numbers in the original source. Ugh. Let me see what I can do.
you should be able to turn on the dev tools and at least walk it back
On Wed, Aug 19, 2015 at 10:41 AM Mike McKay notifications@github.com wrote:
Yeah, it's a bit of a nightmare because it is browserified and the source map isn't working, so I can click through and see the lines that are causing the error, but they don't refer to line numbers in the original source. Ugh. Let me see what I can do.
— Reply to this email directly or view it on GitHub https://github.com/calvinmetcalf/crypto-pouch/issues/8#issuecomment-132623223 .
As best I can tell, here is what is happening:
I have a pouchdb that I have applied the crypto function to and some documents are in it. Getting documents, running queries, etc all behave as expected. However, when I try and replicate from this db to an external couchdb it seems to be trying to decrypt each of the documents before replicating them.
The stack trace leads me here:
var decipher = chacha.createDecipher(key, new Buffer(doc.nonce, 'hex')); But doc.nonce is null and this leads to the eventual error.
The nonce field doesn't exist on the doc if crypto has been called. If I call removeCrypto on the database, then get a doc, I see the nonce field on the doc.
Clearly I have no idea what I am talking about ... but It seems to me like it shouldn't be decrypting each doc if the doc is already decrypted.
I posted the above comment and then removed it, because I thought it was inaccurate - but after more investigation it does seem accurate.
I now have a fix. If I change the line from here:
which is currently:
if (turnedOff)
to
if (turnedOff || !doc.nonce)
Then everything works fine. Is this a bug? Of course, I'm happy to send a pull request but I am very much hacking blind here.
Seems like a bug, I can look into it next week when I get back from vacation
On Wed, Aug 19, 2015, 10:29 PM Mike McKay notifications@github.com wrote:
I posted the above comment and then removed it, because I thought it was inaccurate - but after more investigation it does seem accurate.
I now have a fix. If I change the line from here:
which is currently:
if (turnedOff)
to
if (turnedOff || !doc.nonce)
Then everything works fine. Is this a bug? Of course, I'm happy to send a pull request but I am very much hacking blind here.
— Reply to this email directly or view it on GitHub https://github.com/calvinmetcalf/crypto-pouch/issues/8#issuecomment-132807835 .
I added crypto-pouch to my system and it all seems to work fine, except that it fails to do outgoing replications: it fails when I try and do a replicate.to
It seems like it is having trouble decrypting the doc before sending it. It's just a simple JSON doc. Any suggestions on how to debug this?