Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TypeError: Object false has no method 'indexOf' #1187

Closed
timeturner opened this Issue · 19 comments
@timeturner

Generated fresh express@3.0.0beta4 app with no alterations and it prints out this error on attempting to GET /:

TypeError: Object false has no method 'indexOf'
    at Object.exports.parseJSONCookie (/root/test/node_modules/express/node_modules/connect/lib/utils.js:222:16)
    at exports.parseJSONCookies (/root/test/node_modules/express/node_modules/connect/lib/utils.js:207:23)
    at Array.forEach (native)
    at Object.exports.parseJSONCookies (/root/test/node_modules/express/node_modules/connect/lib/utils.js:205:20)
    at Object.cookieParser [as handle] (/root/test/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:52:27)
    at next (/root/test/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.methodOverride [as handle] (/root/test/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5)
    at next (/root/test/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at multipart (/root/test/node_modules/express/node_modules/connect/lib/middleware/multipart.js:52:61)
    at module.exports (/root/test/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9)
GET / 500 4ms

Removing express@3.0.0beta4 and reverting to express@3.0.0beta1 eliminates the issue entirely. Not sure what is causing this.

@tj
tj commented

works fine for me

@tj
tj commented

closing until we have more info, all tests pass and I'm able to fire up a new app no problem

@tj tj closed this
@mpaland

Seems an issue of the cookieParser

works:
app.use(express.cookieParser());

produces error above:
app.use(express.cookieParser('some secret'));

@userIsNaN

I can second this, I've had the same experience since upgrading to beta4 (same reproduction steps as @mpaland)

@tj
tj commented

do you guys have a setup i can use to reproduce it? is it random?

@PuerkitoBio

Here's my server configuration. Just setup a route on '/' to render a page, it crashes every time (not random) with a secret. Rollbacked to beta3 and it works. Thanks to @mpaland for isolating the cause.

var express = require('express'),
app = express(),
path = require('path'),
rootDir = path.resolve(__dirname, '..')

app.configure(function() {
app.set('views', rootDir + '/views')
app.set('view engine', 'jade')
app.use(express.static(rootDir + '/public'))
app.use(express.bodyParser())
app.use(express.cookieParser('toto'))
app.use(express.session())
app.use(app.router)
})

app.configure('development', function () {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
})

@tj
tj commented

ok thanks guys ill take a look in a bit

@aledbf

I can reproduce this too but there's a weird thing, the error only occurs if I use Chrome. In Safari, Firefox and IE works fine.

@defunctzombie
Collaborator

I ran the provided server config example (it was incomplete so I added a listen and a route for /) and everything worked in chrome.

@aledbf

I "found" the problem. It's related to the signed cookies.
To reproduce the problem:

  1. Use the examples/session/Redis.js as test case.
  2. Start the application
  3. Browse http://localhost:3000
  4. Stop the application and change the secret.
  5. Browse http://localhost:3000
@PuerkitoBio
@tbergeron

I'm having the same issue as people in here.

DEBUG: TypeError: Object false has no method 'indexOf'
    at Object.exports.parseJSONCookie (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/utils.js:222:16)
    at exports.parseJSONCookies (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/utils.js:207:23)
    at Array.forEach (native)
    at Object.exports.parseJSONCookies (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/utils.js:205:20)
    at Object.cookieParser [as handle] (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:52:27)
    at next (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.methodOverride [as handle] (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5)
    at next (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at multipart (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/middleware/multipart.js:52:61)
    at module.exports (/Users/tommybergeron/Documents/Brainpad/ThinAir/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9)
@Keats

Same here, having a secret in cookieParser is the problem, no issue if we don't specify it.

@tj
tj commented

3.0.0beta5 should be fine

@bmcmahen

For what it's worth, I'm having the same error in 3.0.0beta 4.

@fatjonny

3.0.0beta5 did indeed fix this error for me.

@doortts

I had a same issue and found (probably) reason.
So I send a pull request.

see the below link.

doortts/connect@0d20774

@tj
tj commented

try/catch is (almost) always the wrong solution, this should be resolved now

@alejonext

I realize that is a mistake, with NodeJs method. That is sometimes the engine fails. If however if you should not reopen this issuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.