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

TypeError: Object.defineProperties called on non-object #166

Open
matteocrippa opened this issue Apr 17, 2012 · 11 comments
Open

TypeError: Object.defineProperties called on non-object #166

matteocrippa opened this issue Apr 17, 2012 · 11 comments

Comments

@matteocrippa
Copy link

Using the latest version from npm i'm experiencing this issue when I connect to a local db and I try to create a database.

Here the code used:

db.exists(function(error, exists){
if(error)
 console.log(error);
else if (exists)
 console.log("ok");
else{
db.create();
db.save('_design/test',{
  all: { 
   map: function(doc){
    if(doc.name) emit(doc.name, doc);
   }
}
});

Running this code once I receive this error:

/node_modules/cradle/lib/cradle/response.js:126
return Object.defineProperties(obj, descriptor);
^
TypeError: Object.defineProperties called on non-object
at Function.defineProperties (native)
at Object.extend (/node_modules/cradle/lib/cradle/response.js:126:19)
at Request._callback (/node_modules/cradle/lib/cradle.js:187:18)
at Request.callback (/node_modules/cradle/node_modules/request/main.js:119:22)
at Request. (native)
at Request.emit (events.js:70:17)
at Request. (/node_modules/cradle/node_modules/request/main.js:521:16)
at Request.emit (events.js:67:17)
at IncomingMessage. (/node_modules/cradle/node_modules/request/main.js:483:14)
at IncomingMessage.emit (events.js:88:20)

@indexzero
Copy link
Member

You should set { raw: true } when creating your cradle connection.

@pulkitsinghal
Copy link

{raw:true} didn't help me ... I started noticing this error just recently and I'm wondering if its because of using cradle with couchdb v1.3.0

@indexzero
Copy link
Member

Hmmm ... haven't tests this against CouchDB 1.3.0. I'll reopen this for now.

@indexzero indexzero reopened this May 23, 2013
@pulkitsinghal
Copy link

Thanks @indexzero, I appreciate it.

@shihshen
Copy link

Hi @pulkitsinghal ,
May I know what the name of the database you were trying to create is?
As I know the name of database for couchdb can only be lowercase characters (a-z), digits (0-9), and any of the characters _, $, (, ), +, -, and / are allowed. Must begin with a letter.
And cradle seems doesn't handle well while you try to create an illegal database name.

@shihshen
Copy link

forgot to say that the version of my couchdb is 1.5.0, and the version of my cradle is 0.6.7

@pulkitsinghal
Copy link

@Powpow-Shen I've moved away from CouchDB completely since last year. But as far as i remember I was using names like: wishlist1 and my_wishlist ... nothing more.

@shihshen
Copy link

@pulkitsinghal The names look fine. The fix I sent should be able to fix the issue.

@jcataluna
Copy link

HI, I'm getting the same problem reported on this thread.

  • cradle: last from npm
  • node: v 4.2.3
  • couchdb: v1.6.1

Tested with raw: true and raw: false.

Error stack:

/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/lib/cradle/response.js:133
    return Object.defineProperties(obj, descriptor);
                  ^

TypeError: Object.defineProperties called on non-object
    at Function.defineProperties (native)
    at Object.__dirname.extend (/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/lib/cradle/response.js:133:19)
    at Request._onResponse [as _callback] (/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/lib/cradle.js:221:20)
    at Request.init.self.callback (/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/node_modules/request/request.js:198:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/node_modules/request/request.js:1035:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/home/jcataluna/devel/testMediaVida/testnoapi/node_modules/cradle/node_modules/request/request.js:962:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:441:9)
    at process._tickDomainCallback (node.js:396:17)

I'm creating databases dynamically so I really need it working ;)

Regards.

@shihshen
Copy link

Hi @jcataluna ,
Would you mind also test with the PR I sent
#260

@deathg0d
Copy link

deathg0d commented Oct 30, 2016

I had this problem. But for me it turns out that the error was coming from auth before db creation.

Edit: Never mind. It isn't the auth. I am trying to dynamically create a new db after checking if it already exists. It worked one time. Now I get the error again. Not sure what's causing this!

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

6 participants