laktek / punch

A fun and easy way to build modern websites
http://laktek.github.com/punch
MIT License
1.17k stars 107 forks source link

Getting TypeError: Object.keys called on non-object on Second/First Request #101

Closed bjfish closed 10 years ago

bjfish commented 10 years ago

I am getting the following error on the second request (and sometimes first) after starting the server with 'punch s'. I tried both installing from npm and building from source. Also, I was using the mysite tutorial example.

Here are some environment details

mac 10.8.5
node v0.10.20
npm 1.3.11
Punch version 0.5.38

I would normally submit an issue like this to IRC or mailing list first to confirm it is an issue but I do not see these options.

Thank you for the help.

/Users/username/Documents/punch-test/punch/node_modules/connect/lib/utils.js:276
  Object.keys(res._headers).forEach(function(field){
         ^
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at Object.exports.removeContentHeaders (/Users/username/Documents/punch-test/punch/node_modules/connect/lib/utils.js:276:10)
    at Object.exports.notModified (/Users/username/Documents/punch-test/punch/node_modules/connect/lib/utils.js:319:11)
    at Object.module.exports.validatePublicCache (/Users/username/Documents/punch-test/punch/lib/page_server.js:167:25)
    at /Users/username/Documents/punch-test/punch/lib/page_server.js:223:18
    at callback_handler (/Users/username/Documents/punch-test/punch/lib/page_renderer.js:218:13)
    at MustacheEngine.<anonymous> (/Users/username/Documents/punch-test/punch/lib/page_renderer.js:170:11)
    at MustacheEngine.EventEmitter.emit (events.js:98:17)
    at MustacheEngine.BaseEngine.render (/Users/username/Documents/punch-test/punch/lib/template_engines/base_engine.js:90:15)
    at MustacheEngine.BaseEngine.setContent (/Users/username/Documents/punch-test/punch/lib/template_engines/base_engine.js:47:15)
    at /Users/username/Documents/punch-test/punch/lib/page_renderer.js:180:28
    at run_callback (/Users/username/Documents/punch-test/punch/lib/content_handler.js:321:13)
    at /Users/username/Documents/punch-test/punch/lib/content_handler.js:333:13
    at /Users/username/Documents/punch-test/punch/lib/content_handler.js:197:13
    at /Users/username/Documents/punch-test/punch/lib/content_handler.js:113:12
    at ReaddirReq.Req.done (/Users/username/Documents/punch-test/punch/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js:142:5)
    at ReaddirReq.done (/Users/username/Documents/punch-test/punch/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js:89:22)
    at Object.oncomplete (fs.js:107:15)
flockonus commented 10 years ago

Exactly same config as @bjfish, funny thing my colleague have same version of punch and it works.

Also tried on node 0.10.13 and have the same issue

constantx commented 10 years ago

I'm the colleague @flockonus is referring to, I can confirm this is an issue.

Bart4k commented 10 years ago

I can confirm this issue too. The same problem on Ubuntu 13.04, node.js is from ppa:chris-lea

$ punch s Running Punch server on localhost:9009

/usr/lib/node_modules/punch/node_modules/connect/lib/utils.js:276 Object.keys(res._headers).forEach(function(field){ ^ TypeError: Object.keys called on non-object ... ...

Auk14HP commented 10 years ago

I too can confirm this issue. Installing an older version (~0.5.32) seems to make it so I can get to the second page of the tutorial, but upon reload I encounter the same error detailed above. I was able to repro the same issue all the way back to version 0.5.29.

laktek commented 10 years ago

I pushed a fix in version 0.5.40. (needed to patch connect package for it)

constantx commented 10 years ago

great! Thanks @laktek

cc: @flockonus

Auk14HP commented 10 years ago

I might be missing something, but now when I try npm install -g punch I receive an error along the lines of:

32 warn `git config --get remote.origin.url` returned wrong result (git://github.com/laktek/connect)
CreateProcessW: The system cannot find the file specified.
33 silly exec git "clone" "--mirror" "git://github.com/laktek/connect"
"C:\\Users\\James\\AppData\\Roaming\\npm-cache\\_git-remotes\\git-github-com-laktek-connect-30a1167d"
34 silly git,clone,--mirror,git://github.com/laktek/connect,C:\Users\James\AppData\Roaming\npm-cache\_git
remotes\git-github-com-laktek-connect-30a1167d, spawning
35 error git clone git://github.com/laktek/connect CreateProcessW: The system cannot find the file specified.
36 silly lockFile 30a1167d-git-github-com-laktek-connect git://github.com/laktek/connect
37 silly lockFile a2d6ea2f-connect-laktek-connect connect@laktek/connect
38 error Error: No compatible version found: connect@'laktek/connect'
38 error Valid install targets:
38 error
 ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.6","0.1.0","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.2.6","0.2.7","0.3.0","0.4.0","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4","0.5.5","0.5.6","0.5.7","0.5.8","0.5.9","0.5.10","1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.2.0","1.2.1","1.2.2","1.2.3","1.3.0","1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.4.5","1.4.6","1.5.0","1.5.1","1.5.2","1.6.0","1.6.1","1.6.2","1.6.3","1.6.4","1.7.0","1.7.1","1.7.2","1.7.3","1.8.0","1.8.1","1.8.2","1.8.3","1.8.4","1.8.5","2.0.0","2.0.1","2.0.2","2.0.3","1.8.6","2.1.0","2.1.1","2.1.2","1.8.7","2.1.3","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.3.3","1.9.0","1.9.1","2.3.4","2.3.5","2.3.6","2.3.7","1.9.2","2.3.8","2.3.9","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.5.0","2.6.0","2.6.1","2.6.2","2.7.0","2.7.1","2.7.2","2.7.3","2.7.4","2.7.5","2.7.6","2.7.7","2.7.8","2.7.9","2.7.10","2.7.11","2.8.0","2.8.1","2.8.2","2.8.3","2.8.4","2.8.5","2.8.6","2.8.7","2.8.8","2.9.0","2.9.1","2.9.2","2.10.0","2.10.1"]
38 error     at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:674:10)
38 error     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:589:10
38 error     at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry
client\lib\get.js:138:7)
38 error     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:218:7
38 error     at Object.oncomplete (fs.js:297:15)
39 error If you need help, you may report this log at:
39 error     <http://github.com/isaacs/npm/issues>
39 error or email it to:
39 error     <npm-@googlegroups.com>
40 error System Windows_NT 6.1.7601
41 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "connect@laktek/connect"
42 error cwd c:\Code\WebDesign
43 error node -v v0.8.18
44 error npm -v 1.2.2
45 verbose exit [ 1, true ]

Any idea what could be going wrong here?

bjfish commented 10 years ago

This is working for me now. Npm v1.3.11, Node version v0.10.21. Thanks!

Auk14HP commented 10 years ago

Yeah, still running into the same issue listed yesterday even after updating npm and node. Error: No compatible version found: connect@'laktek/connect'