Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
TypeError: Cannot set property data of #<Object> which has only a getter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  15 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James C.  
View profile  
 More options Mar 4 2011, 9:19 pm
From: "James C." <james.charleswo...@gmail.com>
Date: Fri, 4 Mar 2011 18:19:20 -0800 (PST)
Local: Fri, Mar 4 2011 9:19 pm
Subject: TypeError: Cannot set property data of #<Object> which has only a getter
I just upgraded node to 0.42 and I'm getting this strange error that
does not seem to be very helpful (to me at least). anyone know whats
going on?

TypeError: Cannot set property data of #<Object> which has only a
getter
    at Object.merge (/usr/local/lib/node/.npm/connect/1.0.3/package/
lib/utils.js:55:14)
    at Object.Cookie (/usr/local/lib/node/.npm/connect/1.0.3/package/
lib/middleware/session/cookie.js:26:22)
    at /usr/local/lib/node/.npm/connect/1.0.3/package/lib/middleware/
session.js:316:23
    at /usr/local/lib/node/.npm/connect-mongodb/0.1.1/package/lib/
connect-mongodb.js:133:9
    at [object Object].<anonymous> (/usr/local/lib/node/.npm/mongodb/
0.9.1/package/lib/mongodb/collection.js:447:35)
    at [object Object].emit (events.js:45:17)
    at [object Object].<anonymous> (/usr/local/lib/node/.npm/mongodb/
0.9.1/package/lib/mongodb/db.js:83:12)
    at [object Object].emit (events.js:42:17)
    at Socket.<anonymous> (/usr/local/lib/node/.npm/mongodb/0.9.1/
package/lib/mongodb/connection.js:82:16)
    at Socket.emit (events.js:42:17)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vision media [ Tj Holowaychuk ]  
View profile  
 More options Mar 4 2011, 9:36 pm
From: "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca>
Date: Fri, 4 Mar 2011 18:36:25 -0800
Local: Fri, Mar 4 2011 9:36 pm
Subject: Re: [Express-js] TypeError: Cannot set property data of #<Object> which has only a getter

connect-mongodb is probably not updated to work with connect 1.0. they
should check out what connect-redis does, things
have changed slightly for the data stores

On Fri, Mar 4, 2011 at 6:19 PM, James C. <james.charleswo...@gmail.com>wrote:

--
Tj Holowaychuk
Vision Media
President & Creative Lead

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James C.  
View profile  
 More options Mar 4 2011, 10:09 pm
From: "James C." <james.charleswo...@gmail.com>
Date: Fri, 4 Mar 2011 19:09:07 -0800 (PST)
Local: Fri, Mar 4 2011 10:09 pm
Subject: Re: TypeError: Cannot set property data of #<Object> which has only a getter
Thanks for the quick reply.  Not sure where to go from here. It seems
to only be happening on put and delete requests.  Any ideas? Thanks

James

On Mar 4, 9:36 pm, "vision media [ Tj Holowaychuk ]" <t...@vision-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Charlesworth  
View profile  
 More options Mar 5 2011, 8:02 am
From: James Charlesworth <james.charleswo...@gmail.com>
Date: Sat, 5 Mar 2011 08:02:11 -0500
Local: Sat, Mar 5 2011 8:02 am
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

Okay, looks like connect-mongodb works fine with connect 1.0.  My issue was
fixed by setting 'app.use(express.methodOverride());'
after 'app.use(express.bodyParser());' Must have missed this the first time
in the docs. http://expressjs.com/guide.html#HTTP-Methods

On Fri, Mar 4, 2011 at 10:09 PM, James C. <james.charleswo...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casey Banner  
View profile  
 More options Mar 5 2011, 4:44 pm
From: Casey Banner <kcban...@gmail.com>
Date: Sat, 5 Mar 2011 16:44:17 -0500
Local: Sat, Mar 5 2011 4:44 pm
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter
I'm having this same problem, except on GET requests as well.

conn...@1.0.3
connect-mong...@0.1.1
expr...@2.0.0beta
mong...@0.9.1

Node 0.4.2.

Configuration Code:
var MongoStore = require('connect-mongodb');

// Setup
var app = module.exports = express.createServer();

app.configure(function() {
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.cookieParser());
  app.use(express.session({
    secret: settings.secret,
    store: new MongoStore({dbname: 'uwsched'})
  }));
  app.use(app.router);
  app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));
  app.use(express.static(__dirname + '/public'));

});

Traceback:
6 Mar 04:39:48 - [ERROR] TypeError
TypeError: Cannot set property data of #<Object> which has only a getter
    at Object.merge
(/home/kcbanner/local/node/lib/node/.npm/connect/1.0.3/package/lib/utils.js :55:14)
    at Object.Cookie
(/home/kcbanner/local/node/lib/node/.npm/connect/1.0.3/package/lib/middlewa re/session/cookie.js:26:22)
    at /home/kcbanner/local/node/lib/node/.npm/connect/1.0.3/package/lib/middlewar e/session.js:316:23
    at /home/kcbanner/local/node/lib/node/.npm/connect-mongodb/0.1.1/package/lib/c onnect-mongodb.js:133:9
    at [object Object].<anonymous>
(/home/kcbanner/local/node/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/ collection.js:447:35)
    at [object Object].emit (events.js:45:17)
    at [object Object].<anonymous>
(/home/kcbanner/local/node/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/ db.js:83:12)
    at [object Object].emit (events.js:42:17)
    at Socket.<anonymous>
(/home/kcbanner/local/node/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/ connection.js:82:16)
    at Socket.emit (events.js:42:17)

As Tj mentioned, most likely a compatibility issue. Going to look into
that next.

-Casey

On Sat, Mar 5, 2011 at 8:02 AM, James Charlesworth


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darrell Banks  
View profile  
 More options Mar 6 2011, 10:31 am
From: Darrell Banks <banks.busin...@gmail.com>
Date: Sun, 6 Mar 2011 10:31:06 -0500
Local: Sun, Mar 6 2011 10:31 am
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

On Sat, Mar 5, 2011 at 4:44 PM, Casey Banner <kcban...@gmail.com> wrote:
> I'm having this same problem, except on GET requests as well.

> conn...@1.0.3
> connect-mong...@0.1.1
> expr...@2.0.0beta
> mong...@0.9.1

Hello all, I fixed this error by ensuring that my node was @0.2.6, express
was @1.0.7, and connect was @0.5.10. Try rolling back to those versions,
hope this helps!!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vision media [ Tj Holowaychuk ]  
View profile  
 More options Mar 6 2011, 2:03 pm
From: "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca>
Date: Sun, 6 Mar 2011 11:03:07 -0800
Local: Sun, Mar 6 2011 2:03 pm
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

like i said the mongodb session store needs to be updated to support connect
1.x

On Sun, Mar 6, 2011 at 7:31 AM, Darrell Banks <banks.busin...@gmail.com>wrote:

--
Tj Holowaychuk
Vision Media
President & Creative Lead

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casey Banner  
View profile  
 More options Mar 6 2011, 3:33 pm
From: Casey Banner <kcban...@gmail.com>
Date: Sun, 6 Mar 2011 15:33:23 -0500
Local: Sun, Mar 6 2011 3:33 pm
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter
I'm working on a replacement. Should be something in the next few days.

On Sun, Mar 6, 2011 at 2:03 PM, vision media [ Tj Holowaychuk ]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vision media [ Tj Holowaychuk ]  
View profile  
 More options Mar 6 2011, 3:58 pm
From: "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca>
Date: Sun, 6 Mar 2011 12:58:21 -0800
Local: Sun, Mar 6 2011 3:58 pm
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

reference connect-redis if you need. the only thing new really is accessing
the max-age from the session's cookie like below, when its not a number aka
"req.session.expires = false" it is a browser session cookie so you have to
arbitrarily set the TTL to something reasonable, I just have it set to a day
for connect-redis

var maxAge = sess.cookie.maxAge
  , ttl = 'number' == typeof maxAge
    ? maxAge / 1000 | 0
    : oneDay
  , sess = JSON.stringify(sess);

--
Tj Holowaychuk
Vision Media
President & Creative Lead

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Anthony Crognale  
View profile  
 More options Mar 6 2011, 11:40 pm
From: "Anthony Crognale" <anth...@bitsolar.com>
Date: Sun, 6 Mar 2011 23:40:20 -0500
Local: Sun, Mar 6 2011 11:40 pm
Subject: RE: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

Hey all,

Update, I got connect-mongodb to run without creating errors in the console
(albeit not working yet).

In /usr/local/lib/node/connect-mongodb/lib/ (assuming that's you're path),
changed the set method:

mongoStore.set = function (hash, sess, fn) {

    try {

        var maxAge = sess.cookie.maxAge,

                ttl = 'number' == typeof maxAge

                ? maxAge / 1000 | 0

                : oneDay

                , sessd = JSON.stringify(sess);

        sess._id = hash;

        //console.log(hash)

      collection.update({_id: hash}, [ttl,sessd], {upsert: true}, function
(err, data) {

        if (data) {

          delete data._id;

          //console.log('data');

        }

        if (fn) {

          //console.log('fn');

          fn.apply(this, arguments);

        }

      });

    } catch (exc) {

      if (fn) {

        fn(exc);

      }

    }

  };

Although I don't think it changes much, I tried editing the get method to
resemble the connect-redis version:

mongoStore.get = function(hash,fn) {

        collection.findOne({_id: hash}, function(err,data) {

                try {

                        if(!data) return fn();

                        fn(null,JSON.parse(data.toString()));

                } catch (err) {

                        fn(err);

                }

        });

};

After running with mongostore, I was able to log the hash to the console and
confirm that it matched the hash inside of the cookie as well as the
expiration date. It's still not working though as I'm not able to access the
session in the app, tried rendering the id of something I set in the session
to a view but it's coming up as undefined. I'll hack at it more tomorrow.

Hope this helps,

-Anthony C

From: express-js@googlegroups.com [mailto:express-js@googlegroups.com] On
Behalf Of vision media [ Tj Holowaychuk ]
Sent: Sunday, March 06, 2011 3:58 PM
To: express-js@googlegroups.com
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of
#<Object> which has only a getter

reference connect-redis if you need. the only thing new really is accessing
the max-age from the session's cookie like below, when its not a number aka
"req.session.expires = false" it is a browser session cookie so you have to
arbitrarily set the TTL to something reasonable, I just have it set to a day
for connect-redis

                        var maxAge = sess.cookie.maxAge

                         , ttl = 'number' == typeof maxAge

                           ? maxAge / 1000 | 0

                           : oneDay

                         , sess = JSON.stringify(sess);

On Sun, Mar 6, 2011 at 12:33 PM, Casey Banner <kcban...@gmail.com> wrote:

I'm working on a replacement. Should be something in the next few days.

On Sun, Mar 6, 2011 at 2:03 PM, vision media [ Tj Holowaychuk ]

<mailto:express-js%2Bunsubscribe@googlegroups.com> .

<mailto:express-js%2Bunsubscribe@googlegroups.com> .

> For more options, visit this group at
> http://groups.google.com/group/express-js?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Express" group.
To post to this group, send email to express-js@googlegroups.com.
To unsubscribe from this group, send email to
express-js+unsubscribe@googlegroups.com
<mailto:express-js%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/express-js?hl=en.

--
Tj Holowaychuk
Vision Media
President & Creative Lead

--
You received this message because you are subscribed to the Google Groups
"Express" group.
To post to this group, send email to express-js@googlegroups.com.
To unsubscribe from this group, send email to
express-js+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/express-js?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casey Banner  
View profile  
 More options Mar 8 2011, 12:33 am
From: Casey Banner <kcban...@gmail.com>
Date: Tue, 8 Mar 2011 00:33:00 -0500
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter
Hey guys,

I have a replacement ready here: https://github.com/kcbanner/connect-mongo

Just finished the first iteration, so docs are coming soon. However,
there are tests for each method of the store.

The major pitfall with the old library was that it was trying to save
the session object directly to the database, however Connect assumes
that it will be JSON.stringify()ed first. So, more data fields than
Connect intended were making it into the DB, and this was causing
merge to barf when the session was eventually loaded. Basically I just
JSON.stringify the session and put that into a mongo document. This
kinda feels kludgy, but it has the benefit of making this library
future-proof for changes to the structure of sessions.

Let me know what you think. I'll put it into npm when I have time (very soon).

-Casey


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vision media [ Tj Holowaychuk ]  
View profile  
 More options Mar 8 2011, 11:41 am
From: "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca>
Date: Tue, 8 Mar 2011 08:41:41 -0800
Local: Tues, Mar 8 2011 11:41 am
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

you dont _have_ to, but JSON will work best, I believe in a few spots I do
new Date() but you can still pass a valid date to that so it should work
fine if you just have a mongo document, but im not sure how well a Session
will be serialized to BSON with mongo, havent tried

--
Tj Holowaychuk
Vision Media
President & Creative Lead

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Charlesworth  
View profile  
 More options Mar 10 2011, 9:11 pm
From: James Charlesworth <james.charleswo...@gmail.com>
Date: Thu, 10 Mar 2011 21:11:46 -0500
Local: Thurs, Mar 10 2011 9:11 pm
Subject: Re: [Express-js] Re: TypeError: Cannot set property data of #<Object> which has only a getter

Thank you for your time updating this and providing it to the community!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Milne  
View profile  
 More options Mar 22 2011, 1:44 am
From: Tony Milne <tony.mi...@gmail.com>
Date: Mon, 21 Mar 2011 22:44:58 -0700 (PDT)
Local: Tues, Mar 22 2011 1:44 am
Subject: Re: TypeError: Cannot set property data of #<Object> which has only a getter
The error was occurring in Express session.js and cookie.js (as a
result of the connect-mongodb code/data structure).

Basically, the cookie constructor was trying to merge the properties
of the options object being passed in, but choked on the data
property, because the cookie.js file only provides a get data() but no
set data().

A hack to get around this is to strip out the cookie.data in connect-
mongodb get() - which by the way, is a totally redundant copy of the
rest of the cookie data.

Replacing the existing mongoStore.get function with this one should
make the connect-mongodb lib work once again:

  mongoStore.get = function (hash, fn) {
    collection.findOne({_id: hash}, function (err, data) {
      try {
        if (data) {
          delete data._id;
          if (data.cookie && data.cookie.data) {
            delete data.cookie.data;
          }
        }
        // TODO: fail if expired
        fn(null, data);
      } catch (exc) {
        fn(exc);
      }
    });
  };


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casey Banner  
View profile  
 More options Mar 22 2011, 12:33 pm
From: Casey Banner <kcban...@gmail.com>
Date: Tue, 22 Mar 2011 12:33:14 -0400
Local: Tues, Mar 22 2011 12:33 pm
Subject: Re: [Express-js] TypeError: Cannot set property data of #<Object> which has only a getter
Check out the connect-mongo module. I wrote a new mongo session store
when Connect 1.0.x came out, it may work better. I believe the cookie
serializes to JSON without the duplicate data.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »