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)
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:
> 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 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.
-- Tj Holowaychuk Vision Media President & Creative Lead
media.ca> wrote:
> 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:
> > 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 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.
> --
> Tj Holowaychuk
> Vision Media
> President & Creative Lead
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:
> 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- > media.ca> wrote: > > 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:
> > > 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 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.
> > -- > > 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.
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
<james.charleswo...@gmail.com> wrote: > 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:
>> 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- >> media.ca> wrote: >> > 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:
>> > > 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 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.
>> > -- >> > 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 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.
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!!
> 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 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.
-- Tj Holowaychuk Vision Media President & Creative Lead
>> 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 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.
> -- > 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.
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
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 ] > <t...@vision-media.ca> wrote: > > 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:
> >> 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.
> >> 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 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.
> > -- > > 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 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.
-- Tj Holowaychuk Vision Media President & Creative Lead
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 ]
>> 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 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
> -- > 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
-- 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.
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).
> 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 ] > <t...@vision-media.ca> wrote: >> 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:
>>> 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.
>>> 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 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.
>> -- >> 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 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.
> -- > 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 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 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
> 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
> On Sun, Mar 6, 2011 at 11:40 PM, Anthony Crognale <anth...@bitsolar.com> > wrote: > > 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:
> > 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 ] > > <t...@vision-media.ca> wrote: > >> 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:
> >>> 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.
> >>> 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 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.
> >> -- > >> 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 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.
> > -- > > 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 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 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.
-- Tj Holowaychuk Vision Media President & Creative Lead
> 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
> On Sun, Mar 6, 2011 at 11:40 PM, Anthony Crognale <anth...@bitsolar.com> > wrote: > > 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:
> > 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 ] > > <t...@vision-media.ca> wrote: > >> 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:
> >>> 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.
> >>> 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 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.
> >> -- > >> 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 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.
> > -- > > 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 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 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.
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);
}
});
};
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.
On Tuesday, March 22, 2011, Tony Milne <tony.mi...@gmail.com> wrote: > 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:
> -- > 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.