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

Node 6.2.2.: TypeError: undefined is not a function #665

Closed
xbolshe opened this issue Jun 18, 2016 · 7 comments
Closed

Node 6.2.2.: TypeError: undefined is not a function #665

xbolshe opened this issue Jun 18, 2016 · 7 comments

Comments

@xbolshe
Copy link

xbolshe commented Jun 18, 2016

Environment:
Node 6.2.2
SQLite3 3.13.0
node-sqlite3 3.1.4

Issue:

root@quark:/usr/lib# node

var sqlite3 = require('sqlite3');
undefined
var db = new sqlite3.Database(':memory:');
undefined
undefined:0

TypeError: undefined is not a function
root@quark:/usr/lib#

Code sample:

var sqlite3 = require('sqlite3');
var db = new sqlite3.Database(':memory:');

sqlite3 works well
root@quark:/usr/lib# sqlite3
SQLite version 3.13.0 2016-05-18 10:57:30
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open ex1.db
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>

BR,
xbolshe

@lvivier
Copy link
Contributor

lvivier commented Jun 20, 2016

I couldn't repro this on OS X 10.11.6, with node@6.2.2 and node-sqlite3@3.1.4. Did you do anything special when installing node-sqlite3? What happens if you remove it from node_modules and reinstall?

@xbolshe
Copy link
Author

xbolshe commented Jun 23, 2016

I use preinstalled node-sqlite3 to custom Linux image for Intel Galileo board. Previously there was no problem.

I have repeated the same problem with a full recompilations of Linux image with downrgaded packages (Kernel 3.19.8+BusyBox+and so on+NodeJS 6.2.1+SQLite 3.12.1+node-sqlite3 3.1.4). It is strange...

@xbolshe
Copy link
Author

xbolshe commented Jun 23, 2016

It seems it is not node-sqlite3 issue. And I close it.

quark login: root
Kernel: Linux quark 3.19.8-yocto-standard #1 Wed Jun 22 22:34:06 MSK 2016 i586 GNU/Linux
Nodejs: v6.2.2, Shared OpenSSL: OpenSSL 1.0.2h 3 May 2016
Thu Jun 23 20:41:22 UTC 2016
Temp: 74°C
root@quark:~# cat > a.js
process.on('uncaughtException', function(error) {
console.error('Caught error in process!', error)
})

var sqlite3 = require('sqlite3');
var db = new sqlite3.Database('/home/root/database.db');
db.exec("create table galileo(devid integer,name varchar(20),property varchar(10));");
db.close();

^Z
[1]+ Stopped(SIGTSTP) cat > a.js
root@quark:# node ./a.js
Caught error in process! TypeError: undefined is not a function
Caught error in process! TypeError: undefined is not a function
root@quark:
# node --abort-on-uncaught-exception ./a.js
Uncaught TypeError: undefined is not a function

FROM
Illegal instruction
root@quark:~#

@xbolshe xbolshe closed this as completed Jun 23, 2016
@xbolshe xbolshe reopened this Jun 25, 2016
@xbolshe
Copy link
Author

xbolshe commented Jun 25, 2016

Interesting. I have identified a point where it is crashed:
https://github.com/mapbox/node-sqlite3/blob/master/src/database.cc#L199

crash1

@xbolshe
Copy link
Author

xbolshe commented Jun 25, 2016

My research has led to the nodejs/nan#284
Note that EMIT_EVENT uses MakeCallback.

BR,
xbolshe

@xbolshe
Copy link
Author

xbolshe commented Jun 25, 2016

It seems I have fixed the issue:

crash2

I'll provide PR after a clean build.

BR,
xbolshe

@xbolshe
Copy link
Author

xbolshe commented Jun 26, 2016

So here is the PR: #670
After fixing it looks like:

var sqlite3 = require('sqlite3');
function mycallback(data) {
  console.log('mycallback: data='+data);
}
var db      = new sqlite3.Database('/homes/root/database.db',mycallback);
var db      = new sqlite3.Database('/home/root/database.db',mycallback);
db.exec("create table galileo(devid integer,name varchar(20),property varchar(10));");
db.close(); 

crash4

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

3 participants