petersirka/nosql

Uncaught SyntaxError: Unexpected string

Closed this issue · 9 comments

Hey @petersirka , i'm using nosql inside a electron.js and sometimes i'm getting this error;

"Uncaught SyntaxError: Unexpected string", 
source: /Users/vruno/Documents/Urucas/Node/paw/node_modules/nosql/index.js (22)

I change index.js to the unminified version to get the exact line fo the error, and got:

"Uncaught SyntaxError: Unexpected string", source: 
/Users/vruno/Documents/Urucas/Node/paw/node_modules/nosql/index.js (1203)

which is:

self.meta = JSON.parse(data.toString('utf8'));

I believe this should throw an error when it cant parse the meta info, but It's kinda unsual 'cause it only happens sometimes.

Did you had this problem ?

Here's the meta file

{"version":"v3.0.1","views":{},"stored":{},"description":"Paw documents database","created":"2015-06-14T19:38:46.347Z","custom":{"key":"com.urucas.paw:v0.0.1"}}

Custom key, should be an (integer) ?

I shouldnt be setting the description or custom key everytime i'm running my app ?

var self = this;
      self.nosql = require('nosql').load('./db/paw.sql');
      self.nosql.description('Paw documents database');
      self.nosql.custom({key: 'com.urucas.paw:v0.0.1'});

or that's OK ?

Hi @vrunoa,
can you send me all database files on my e-mail? I'll test it.

...the description or custom key everytime...
It's ok.

It's a small database, I'm just starting this project.

Here is the .nosql:

{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"yuijkljkl","date":"2015-06-13T16:18:09.172Z","id":1434212289172,"foot":"left"}
{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"lsls","date":"2015-06-13T16:19:29.929Z","id":1434212369929,"foot":"right"}
{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"test","date":"2015-06-13T16:21:58.445Z","id":1434212518445,"foot":"right"}
{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"test asdas","date":"2015-06-13T16:22:40.717Z","id":1434212560717,"foot":"right"}
{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"test ajkshdka","date":"2015-06-13T16:23:34.220Z","id":1434212614220,"foot":"right"}
{"options":{"rotation":0,"grayscale":false,"temperature":false,"sharpen":true,"pois":[],"feet":"left"},"name":"taskhdgsk","date":"2015-06-13T16:25:08.230Z","id":1434212708230,"foot":"right"}

I'll try to debug a bit more, and let you know if I found the error.

I need all database files, can you send me them on my e-mail?
Thanks :-)

PS: meta data has own file.

Yeah, sorry. I just sent you an email with those files zipped.

I found it kinda hard to debug 'cause it's only happening sometimes.

Hi @vrunoa,
I have tested it and I don't see any problem. Everything works in OSX and in Windows 7.

var db = require('nosql').load('paw.sql');

db.on('ready', function() {
    console.log('---->', db.custom(), db.description());
});

db.all(n => n, (err, docs) => console.log(docs));

Can you send me how to simulate the problem?
Thanks.

I hard to tell you how to simulate the error 'cause it only happens sometimes. I'll try to found how(or when) this error is produced and send you feedback.

OK, I wait for you 👍