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

server-nodejs crash #166

Closed
remyla opened this issue Dec 17, 2016 · 1 comment
Closed

server-nodejs crash #166

remyla opened this issue Dec 17, 2016 · 1 comment
Milestone

Comments

@remyla
Copy link
Owner

remyla commented Dec 17, 2016

when performing this read:

$ damas read tests/test4

GET /api/verify/ 200 2.679 ms - 216
[ '/tests/test4' ]

/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/utils.js:99
process.nextTick(function() { throw err; });
^
TypeError: Cannot read property 'length' of undefined
at /home/primcode/bin/damas-core/server-nodejs/db/mongodb.js:117:51
at Array.reduce (native)
at /home/primcode/bin/damas-core/server-nodejs/db/mongodb.js:115:39
at handleCallback (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/utils.js:96:56)
at /home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/cursor.js:853:16
at handleCallback (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:172:5)
at setCursorDeadAndNotified (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:507:3)
at nextFunction (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:655:7)
at Cursor.next [as _next] (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:696:3)
at fetchDocs (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/cursor.js:849:10)

@remyla
Copy link
Owner Author

remyla commented Dec 18, 2016

Here is the debug result:

"/tests/test4" is exactly 12 bytes and for some reasons mongoDB ObjectID.isValid("/tests/test4") returns true.

Here are some discussions about this issue:

Automattic/mongoose#1959
http://stackoverflow.com/questions/11985228/mongodb-node-check-if-objectid-is-valid

replacing

  •    if (ObjectID.isValid(id)) {
    

with this (testing if it is exactly a 24 hex)

  •    if (/^[a-fA-F0-9]{24}$/.test(id) && ObjectID.isValid(id)) {
    

fixes the issue

@remyla remyla closed this as completed in 6cbad4e Dec 18, 2016
@remyla remyla modified the milestones: 2.3.5, 2.3.6 Dec 18, 2016
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

1 participant