sciencefair-land / sciencefair

The futuristic, fabulous and free desktop app for working with scientific literature :microscope: :book:
https://sciencefair-app.com
MIT License
603 stars 52 forks source link

[v1.0.4] TypeError: Cannot convert undefined or null to object #107

Closed blahah closed 7 years ago

blahah commented 7 years ago

https://sentry.io/codeforscience/sciencefair/issues/302489702/

TypeError: Cannot convert undefined or null to object
  at Function.keys (<anonymous>)
  at DBEntries._transform (/Applications/ScienceFair.app/Contents/Resources/app.asar/node_modules/search-index-adder/lib/delete.js:70:27)
  at dispatchError (/Applications/ScienceFair.app/Contents/Resources/app.asar/node_modules/levelup/lib/util.js:25:35)

cc @fergiemcdowall

blahah commented 7 years ago

@fergiemcdowall I've started seeing this a lot since upgrading search-index to the latest version. Have you seen it before?

fergiemcdowall commented 7 years ago

Ah yes- I made a small API change to search-index@0.13.0. Since search-index is still in beta (0.x.x), these breaking changes dont get a major version bump- on reflection, maybe its time that they did.

Anyway, long story short- when adding docs you now use feed:

fs.createReadStream('data.json')            // <- from a file
  .pipe(myIndex.feed())
  .on('finish', function() {  /* done */ })

or

myReadStream                                // <- a readable stream of objects
  .pipe(myIndex.feed({ objectMode: true }))
  .on('finish', function() {  /* done */ })

(The old .defaultPipeline -> .add will still work if you set objectMode in the options of .defaultPipeline)

blahah commented 7 years ago

@fergiemcdowall aha! Thanks for the explanation and I'm just happy it was something simple :D

Fix incoming

blahah commented 7 years ago

@fergiemcdowall does this only apply to adding? in particular, is the del API the same?

fergiemcdowall commented 7 years ago

.del should be unchanged.

blahah commented 7 years ago

Fixed in https://github.com/blahah/yunodb/commit/0fcdb81a19e5ef18553fb8b6cfb2981d08798cc7

This also fixes #104 and #112

blahah commented 7 years ago

still happening in v1.0.5 - issue is somewhere in the del method of search-index.

for now, working around this by updating only the document in yunodb: https://github.com/blahah/yunodb/commit/62a7cd806b97b5e1e8e284a392aa1fa0d716c94f