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

Error 500 in production mode on Windows #84

Closed
ghost opened this issue Jan 4, 2014 · 22 comments
Closed

Error 500 in production mode on Windows #84

ghost opened this issue Jan 4, 2014 · 22 comments

Comments

@ghost
Copy link

ghost commented Jan 4, 2014

Hello,

I have Error 500 in production mode

My test:

I'm on Win 7 64b.

First, I have created a new project in D:\nodejs\www with kraken:

D:\nodejs\www>
D:\nodejs\www>yo kraken
     ,'""`.
    / _  _ \
    |(@)(@)|   Release the Kraken!
    )  __  (
   /,'))((`.\
  (( ((  )) ))
   `\ `)(' /'

[?] Application name: testProduction
[?] Description: test production mode
[?] Author: esus62
[?] Use RequireJS? (Y/n) Y

I go in D:\nodejs\www\testProduction and start app

D:\nodejs\www\testProduction>
D:\nodejs\www\testProduction>node index.js
Multipart body parsing will be disabled by default in future versions. To enable, use `middleware:multipart` configuration.
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Listening on 8000
127.0.0.1 - - [Sat, 04 Jan 2014 21:17:12 GMT] "GET / HTTP/1.1" 200 276 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
127.0.0.1 - - [Sat, 04 Jan 2014 21:17:15 GMT] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

In Chrome, I go to http://localhost:8000/ and i see Hello, testproduction!
It's OK

Secondly, I stop node and I set NODE_ENV:

D:\nodejs\www\testProduction>set NODE_ENV=production

D:\nodejs\www\testProduction>echo %NODE_ENV%
production

I build with grunt:

D:\nodejs\www\testProduction>grunt build
Running "jshint:files" (jshint) task
>> 2 files lint free.

Running "less:build" (less) task
File .build/css/app.css created.

Running "requirejs:build" (requirejs) task

Tracing dependencies for: app
Uglifying file: D:/nodejs/www/testProduction/.build/js/app.js
Uglifying file: D:/nodejs/www/testProduction/.build/js/config.js

app.js
----------------
config.js
app.js


Running "copyto:build" (copyto) task
Copied 629 files (1 unchanged), created 163 folders

Running "clean:tmp" (clean) task

Running "clean:build" (clean) task
Cleaning .build/templates...OK

Running "makara:files" (makara) task

Running "dustjs:build" (dustjs) task

Running "clean:tmp" (clean) task

Done, without errors.

I restart node, I go to http://localhost:8000/ and i see Error 500 ...

D:\nodejs\www\testProduction>node index.js
Multipart body parsing will be disabled by default in future versions. To enable
, use `middleware:multipart` configuration.
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Listening on 8000
Error:Failed to lookup view "index"
Error: Failed to lookup view "errors/500"
    at Function.app.render (D:\nodejs\www\testProduction\node_modules\express\lib\application.js:493:17)
    at Function.clobbered [as render] (D:\nodejs\www\testProduction\node_modules\makara\lib\view\js.js:49:20)
    at ServerResponse.res.render (D:\nodejs\www\testProduction\node_modules\express\lib\response.js:798:7)
    at ServerResponse.app.response.render (D:\nodejs\www\testProduction\node_modules\kraken-js\lib\patch\stream.js:71:32)
    at Object.handle (D:\nodejs\www\testProduction\node_modules\kraken-js\lib\middleware\error.js:60:21)
    at next (D:\nodejs\www\testProduction\node_modules\express\node_modules\connect\lib\proto.js:188:17)
    at IncomingMessage.next (D:\nodejs\www\testProduction\node_modules\express\node_modules\connect\lib\proto.js:190:11)
    at fn (D:\nodejs\www\testProduction\node_modules\kraken-js\lib\patch\stream.js:48:30)
    at Function.app.render (D:\nodejs\www\testProduction\node_modules\express\lib\application.js:495:14)
    at Function.clobbered [as render] (D:\nodejs\www\testProduction\node_modules\makara\lib\view\js.js:49:20)
127.0.0.1 - - [Sat, 04 Jan 2014 21:28:55 GMT] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

Is a bug or have I forgot anything?

@lmarkus
Copy link
Contributor

lmarkus commented Jan 5, 2014

It's a bug. And a nasty one at that.
It belongs to one of Kraken's dependencies. I've filed it against makara: krakenjs/makara/issues/22

The only workaround that I can suggest, is to work in dev mode for the time being 😦

@jeffharrell
Copy link
Member

Updating the title to reflect it's running on Windows.

@debajyotisarma
Copy link

@lmarkus
What settings we need to change to use dev mode ?
Is it process.env.NODE_ENV or something else?

@pvenkatakrishnan
Copy link
Member

yes that is the env variable. By default app runs in dev mode. You will have to force set it to production if you want to check it out in that mode.

@lmarkus
Copy link
Contributor

lmarkus commented Jan 13, 2014

Correct, it's NODE_ENV.

Just in case, because you specifically said process.env.NODE_ENV, you should be setting it from the environment, not from within node.

(And as poornima said, if it is not set, it's defaulting to development)

@debajyotisarma
Copy link

I tried both production and development mode for NODE_ENV , in both nodejs code and set command of cmd.
But faced the same error.

@alexsantos
Copy link

To be able to run in production mode you must first have to run grunt build.
Alex
Em 14/01/2014 04:39, "debajyotisarma" notifications@github.com escreveu:

I tried both production and development mode for NODE_ENV , in both nodejs
code and set command of cmd.
But faced the same error.


Reply to this email directly or view it on GitHubhttps://github.com//issues/84#issuecomment-32238298
.

@debajyotisarma
Copy link

@alexsantos I have run grunt build and templates got fill in .build/templates and public/templates directory
But yet I faced this :

Express
500 Error: Failed to lookup view "errors/500"
at Function.app.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:493:17)
at Function.clobbered as render
at ServerResponse.res.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\response.js:798:7)
at ServerResponse.app.response.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:71:32)
at Object.handle (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\middleware\error.js:60:21)
at next (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:188:17)
at IncomingMessage.next (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:190:11)
at fn (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:48:30)
at Function.app.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:495:14)
at Function.clobbered as render

@alexsantos
Copy link

That error happened to me on production mode every time the grunt build
didn't work completely but on development it always worked. When running
npm start, do you have any errors?

Alex

2014/1/14 debajyotisarma notifications@github.com

@alexsantos https://github.com/AlexSantos I have run grunt build and
templates got fill in .build/templates and public/templates directory
But yet I faced this :

Express
500 Error: Failed to lookup view "errors/500"
at Function.app.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:493:17)
at Function.clobbered as render
at ServerResponse.res.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\response.js:798:7)
at ServerResponse.app.response.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:71:32)
at Object.handle
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\middleware\error.js:60:21)
at next
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:188:17)
at IncomingMessage.next
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:190:11)
at fn
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:48:30)
at Function.app.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:495:14)
at Function.clobbered as render


Reply to this email directly or view it on GitHubhttps://github.com//issues/84#issuecomment-32249887
.

@debajyotisarma
Copy link

@alexsantos

I tried both
set process.env.NODE_ENV='development'; in index.js
and
System Properties => Advance => Environment Variables => NODE_ENV=development

npm start runs without errors but faced template error when hit localhost:3000.

console log

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\deba.jyoti>cd gitcode\frontend\click2call

C:\Users\deba.jyoti\gitcode\frontend\click2call>npm start

click2call-new@0.0.1 start C:\Users\deba.jyoti\gitcode\frontend\click2call
node index.js

Multipart body parsing will be disabled by default in future versions. To enable, use middleware:multipart configuration.
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Listening on 3000
Error:Invalid template [layouts/master]
Error: Failed to lookup view "errors/500"
at Function.app.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:493:17)
at Function.clobbered as render
at ServerResponse.res.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\response.js:798:7)
at ServerResponse.app.response.render (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:71:32)
at Object.handle (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\middleware\error.js:60:21)
at next (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:188:17)
at IncomingMessage.next (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:190:11)
at fn (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:48:30)
at Stub.callback (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\adaro\lib\engine.js:126:22)
at Stub.flush (C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\dustjs-linkedin\lib\dust.js:263:12)
127.0.0.1 - - [Tue, 14 Jan 2014 11:01:47 GMT] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

@alexsantos
Copy link

Did you see the error about layouts/master?
Em 14/01/2014 11:17, "debajyotisarma" notifications@github.com escreveu:

@alexsantos https://github.com/AlexSantos

I tried both
set process.env.NODE_ENV='development'; in index.js
and
System Properties => Advance => Environment Variables =>
NODE_ENV=development

npm start runs without errors but faced template error when hit
localhost:3000.
console log

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\deba.jyoti>cd gitcode\frontend\click2call

C:\Users\deba.jyoti\gitcode\frontend\click2call>npm start

click2call-new@0.0.1 start C:\Users\deba.jyoti\gitcode\frontend\click2call
node index.js

Multipart body parsing will be disabled by default in future versions. To
enable, use middleware:multipart configuration.
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for
alternatives
connect.limit() will be removed in connect 3.0
Listening on 3000
Error:Invalid template [layouts/master]
Error: Failed to lookup view "errors/500"
at Function.app.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\application.js:493:17)
at Function.clobbered as render
at ServerResponse.res.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\lib\response.js:798:7)
at ServerResponse.app.response.render
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:71:32)
at Object.handle
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\middleware\error.js:60:21)
at next
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:188:17)
at IncomingMessage.next
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\express\node_modules\connect\lib\proto.js:190:11)
at fn
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\kraken-js\lib\patch\stream.js:48:30)
at Stub.callback
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\adaro\lib\engine.js:126:22)
at Stub.flush
(C:\Users\deba.jyoti\gitcode\frontend\click2call\node_modules\dustjs-linkedin\lib\dust.js:263:12)
127.0.0.1 - - [Tue, 14 Jan 2014 11:01:47 GMT] "GET / HTTP/1.1" 500 - "-"
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/31.0.1650.63 Safari/537.36"


Reply to this email directly or view it on GitHubhttps://github.com//issues/84#issuecomment-32256633
.

@lmarkus
Copy link
Contributor

lmarkus commented Jan 22, 2014

@debajyotisarma instead of setting the NODE_ENV parameter within the process can you set it externally as an environment variable.

@debajyotisarma
Copy link

@lmarkus what is the command to set NODE_ENV in windows7 ?
or shall I set it via System Properties => Advance => Environment Variables => NODE_ENV=development

@lmarkus
Copy link
Contributor

lmarkus commented Jan 22, 2014

You can do it via GUI exactly as you described, or from the command line (one time use):
SET NODE_ENV=development

you can then echo %NODE_ENV% to verify it was set correctly

@debajyotisarma
Copy link

@lmarkus
I have using SET NODE_ENV=development and echo %NODE_ENV%
but I am facing the facing the same error.

Whats the farther step to debug this?

@lmarkus
Copy link
Contributor

lmarkus commented Jan 22, 2014

Make sure you have the latest versions of Kraken and generator-kraken (both 0.7.0)
Create a new plain vanilla kraken app. Make sure that you say yes on the requireJS prompt
Doublecheck that NODE_ENV is development.
npm start

You should NOT see this message about memory sessions:

Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.

Visit http://127.0.0.1:8000/

If that still fails, can you list the error message again, and also the contents of your .build directory.

@debajyotisarma
Copy link

@lmarkus
I create a simple app following http://krakenjs.com/#Quick with Kraken and generator-kraken (both 0.7.0) , SET NODE_ENV=development
and able to see hello page on http://127.0.0.1:8000/

[So removing my previous post and created https://github.com//issues/107]

@jeffharrell
Copy link
Member

@debajyotisarma Just to note, you don't actually need to set your NODE_ENV to development. That is what it is by default and you really only need to change it if you want to run in production or a custom mode. Note that it won't hurt if you set it to development, it's just implied.

I'm glad this seems like it was resolved. My guess is that you had some dust issue preventing it from rendering given the Error:Invalid template [layouts/master] error above.

Are we okay to close this out then?

@debajyotisarma
Copy link

@jeffharrell
Sorry if I have we have arrived to wrong conclusion...
Sample plain app works fine.
The real app I am working works fine in ubuntu.
But, doesn't work on windows(with same code base and instructions) and produce the same error posted in original description of this post.
I am wondering if the reporter of this issue was able to solve it or not.

@lmarkus
Copy link
Contributor

lmarkus commented Jan 22, 2014

The original issue remains open, until we address krakenjs/makara#22

@debajyotisarma, so the generated app works correctly. This means that it's an issue specific to something in your more complex application. Can you point me to a github repo that I can clone, and reproduce the problem with?

@jeffharrell
Copy link
Member

It looks like from the commentary on krakenjs/makara#22 that you have a solution in mind. PR that?

@lmarkus
Copy link
Contributor

lmarkus commented Jan 30, 2014

Fixed via
krakenjs/makara@d77202e and krakenjs/generator-kraken@e949cf6
A new package will be published shortly. But you will need to update your Gruntfile as well:

Your update should match https://github.com/paypal/generator-kraken/pull/50/files

                    fullname: function (filepath) {
                        var path = require('path'),
                            name = path.basename(filepath, '.dust'),
                        //Hardcoded to forwards slash on purpose. This is due to the way that grunt handles globbing.
                        //Patterns like **/*.dust are always expanded using '/' with no consideration to the host OS
                        //separator. This caused issues when trying to build on win_32
                            parts = filepath.split('/'),
                            fullname = parts.slice(3, -1).concat(name);

                        //Hardcoded to forwards slash on purpose. Keeps compatibility on win_32
                        return fullname.join('/');
                    }

@lmarkus lmarkus closed this as completed Jan 30, 2014
@ghost ghost unassigned lmarkus Apr 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants