aerospike / aerospike-client-nodejs

Node.js client for the Aerospike database
https://www.aerospike.com/
Apache License 2.0
201 stars 78 forks source link

undefined bin makes api crash #23

Closed retargetly closed 9 years ago

retargetly commented 9 years ago

Hello, the following code crashes the API and makes a stack dump .

var key = aerospike.key('test','test',1);
var doc = {'bla': 1}
doc.asd = undefined;

client.put(key, doc, function(err) 
{
   //do stuff
});

We cannot handle this error, as this is not being caught by process.on('uncaughtException') or domains. Is this a bug? Is there any way we can handle this kind of errors?

The error is something like this:

Fatal error in ../deps/v8/src/api.h, line 297

CHECK(allow_empty_handle || that != __null) failed

==== Stack trace ============================================

Security context: 0x2ffb4aa06b71 #0# .....

Thanks,

cstivers78 commented 9 years ago

Looks like a bug. It appears undefined may not be handled properly. We will try to get a fix out in the next day.

GayathriKaliyamoorthy commented 9 years ago

We have fixed this and released the fix to npm, you can use the latest version available.

Thanks

retargetly commented 9 years ago

I confirm that this was fixed, thanks!

Federico | CTO http://retargetly.com

On 19/11/2014, at 9:39, Gayathri notifications@github.com wrote:

We have fixed this and released the fix to npm, you can use the latest version available.

Thanks

— Reply to this email directly or view it on GitHub.

pablonazareno commented 9 years ago

I'm having the same issue. I'm using verion 1.0.25.

Thanks

GayathriKaliyamoorthy commented 9 years ago

Hi The latest release has the fix and we are not able to reproduce this inhouse. Could you give us the code snippet for us to dig deeper.

Thanks.

pablonazareno commented 9 years ago

Hi The process don't crush actually, but have some strange behaviour in stored data.

Try this code:

var aerospike = require('aerospike');
var client = aerospike.client(connectionSetting);
client.connect(function(response) {
    if (response.code === aerospike.status.AEROSPIKE_OK) {
        var digest = aerospike.key('test', 'test', 'title');
        var value = {
            header: {
                banners: [],
                apply_banner: "New Year!",
                empty: undefined
            }
        };
        client.put(digest, value, console.log);
    } else {
        console.error('SOMETHING IS WRONG');
    }
});

Generate this output:

Jan 07 2015 14:27:29 GMT: ERROR(5679) [conversions.cc:515] [asval_from_jsobject] - Object passed is undefined
{ code: 0, message: null, func: null, file: null, line: null } { ns: 'test', set: 'test', key: 'title' }

And at Aerospike DB:

ascli get test test title
{"header": { }}

but Using AQL

gt;aql
Aerospike Query
Copyright 2013 Aerospike. All rights reserved.

aql> select * from test.test
Segmentation fault (core dumped)

Thanks

Pablo

GayathriKaliyamoorthy commented 9 years ago

Thanks for giving a detailed description for repro. I could reproduce the exact same issue. We identified the problem and fixed this in nodejs Client API, and will be releasing to npm soon.

Thanks.

iamontheinet commented 9 years ago

Hi Pablo,

The issue has been resolved as of 1.0.30.

Here's the output from running your code snippet:

ASCLI: ascli get test test title Result: {"header": { "banners": [ ], "empty": null, "apply_banner": "New Year!" }}

AQL: select * from test.test Result: {"banners":[], "empty":NIL, "apply_banner":"New Year!"}

Hope this helps.

Dash

GayathriKaliyamoorthy commented 9 years ago

@pablonazareno Could you confirm if this works for you, so that we can close this issue?

Thanks.