I getting errors during start jitsu server.
Please guide me
{"message":"Object #<ServerResponse> has no method 'local'","code":500}
err Mon, 11 Nov 2013 13:13:09 GMT TypeError: Object # has no method 'local'
at Object.module.exports.middleware [as handle]
(/opt/run/snapshot/package/servers/www/middleware/expose.coffee:3:5)
at next (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at multipart (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/multipart.js:90:37)
at module.exports
(/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9)
at urlencoded (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:49:37)
at module.exports
(/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:55:7)
at json (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/json.js:51:37)
at Object.bodyParser [as handle]
(/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at next (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.cookieParser [as handle]
(/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5)
at next (/opt/run/snapshot/package/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.exports.send [as oncomplete]
(/opt/run/snapshot/package/node_modules/connect/lib/middleware/static.js:139:11)
You want res.locals (plural) not res.local
Since this is still not clear enough for #Marco,
open expose.coffee in your text editor
on line 3, change the word "local" to "locals"
save and retry
Related
I am sending the logs produced by my nodejs app using winston
This is my configuration filebeat.yml
filebeat.inputs:
- type: log
paths:
- /var/log/application/*.log
json.keys_under_root: true
output.elasticsearch:
hosts: ["elasticsearch.staging:9200"]
setup.kibana:
host: "kibana.staging:5601"
Logs are written in for example /var/log/application/app-bank.log
I have something like that
{"message":"Application started","level":"info","application":"app-bank","environment":"staging"}
{"message":"Header x-website-name not found","stack":"Error: Header x-website-name not found\n at context.httpApp.use (/usr/src/app/controller/index.js:30:39)\n at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)\n at /usr/src/app/node_modules/express/lib/router/index.js:284:7\n at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)\n at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)\n at context.httpApp.use (/usr/src/app/controller/index.js:25:9)\n at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)\n at /usr/src/app/node_modules/express/lib/router/index.js:284:7\n at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)\n at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)\n at session (/usr/src/app/node_modules/express-session/index.js:468:7)\n at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)\n at /usr/src/app/node_modules/express/lib/router/index.js:284:7","level":"error","application":"app-bank","environment":"staging"}
The first log is received my elasticsearch, but not the second one, I can not see any log, the problem should be because of the stack key I do not know if it because of the format of the stack or the log is passing a certain size.
I fixed it adding
json.add_error_key: true
I am getting the following error showing up in my logger.
URIError: Failed to decode param '/%db<script>alert(539043);</script>/'
at decodeURIComponent (<anonymous>)
at decode_param (/usr/src/app/node_modules/express/lib/router/layer.js:172:12)
at Layer.match (/usr/src/app/node_modules/express/lib/router/layer.js:123:27)
at matchLayer (/usr/src/app/node_modules/express/lib/router/index.js:574:18)
at next (/usr/src/app/node_modules/express/lib/router/index.js:220:15)
at app.use (/usr/src/app/app.js:83:9)
at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
at /usr/src/app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
I think this is someone trying to probe my site for some vulnerability. This occurs 2 times every week like clockwork.
Around the same time I get the following error too:
URIError: Failed to decode param '/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd'
at decodeURIComponent (<anonymous>)
at decode_param (/usr/src/app/node_modules/express/lib/router/layer.js:172:12)
at Layer.match (/usr/src/app/node_modules/express/lib/router/layer.js:123:27)
at matchLayer (/usr/src/app/node_modules/express/lib/router/index.js:574:18)
at next (/usr/src/app/node_modules/express/lib/router/index.js:220:15)
at app.use (/usr/src/app/app.js:83:9)
at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
at /usr/src/app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
Is there some sort of way to prevent this? Should I be concerned about this? Is there a standard way of dealing with parameters that are not legitimate.
Using winston loggers to write contents into the files but that works only when customlogger.error is used. If the node is outputting some reference error like below
ReferenceError: aksbd is not defined
at /home/nigilan/Desktop/homepagelogger/app.js:53:20
at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5)
at next (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5)
at /home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:335:12)
at next (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:275:10)
at /home/nigilan/Desktop/homepagelogger/app.js:38:5
at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5)
How to use winston to store the errors like above ?
P.S. Logging the unhandled exception is nodejs server is working fine.
`
function formatArgs(args){
return [util.format.apply(util.format, Array.prototype.slice.call(args))];
}
console.info = function(){
customlogger.info.apply(customlogger, formatArgs(arguments));
};
console.warn = function(){
customlogger.warn.apply(customlogger, formatArgs(arguments));
};`
Here you can also use the default logger of winston instead of your custom logger. The gist code below has the perfect answer for this.
Below is a snippet from my node.js file
I am trying to compile code from LESS into CSS.
Am I missing anything
app.use(lessMiddleware({
src: path.join(__dirname, '/public/stylesheets/styles', 'less'),
dest: path.join(__dirname, '/public/stylesheets/css'),
prefix : '/stylesheets',
}));
When I refresh my index.html, it throws me below error
TypeError: Arguments to path.join must be strings
at f (path.js:204:15)
at Object.filter (native)
at Object.exports.join (path.js:209:40)
at C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\less-middleware\lib\mi
ddleware.js:161:27
at Layer.handle [as handle_request] (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\n
ode_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\l
ib\router\index.js:312:13)
at C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\lib\router\ind
ex.js:280:7
at Function.process_params (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modul
es\express\lib\router\index.js:330:12)
at next (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\lib\rout
er\index.js:271:10)
at expressInit (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\l
ib\middleware\init.js:33:5)
TypeError: Arguments to path.join must be strings
at f (path.js:204:15)
at Object.filter (native)
at Object.exports.join (path.js:209:40)
at C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\less-middleware\lib\mi
ddleware.js:161:27
at Layer.handle [as handle_request] (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\n
ode_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\l
ib\router\index.js:312:13)
at C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\lib\router\ind
ex.js:280:7
at Function.process_params (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modul
es\express\lib\router\index.js:330:12)
at next (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\lib\rout
er\index.js:271:10)
at expressInit (C:\SrkOwnRepo\Hotaaal\HotelUI10892515\node_modules\express\l
ib\middleware\init.js:33:5)
Please provide a workaround or any other middleware.
The less-middleware function has a different interface than the one you showed in the code snippet.
It looks like this lessMiddleware(source, options), where source is a string and options is an object. And it breaks somewhere around here when it tries to to call path.join on source, in your case an object.
You can check out the documentation of the middleware for the accepted parameters in options.
Am deploying one node js project in a linux evniroment everything is going fine ,but after 12 to 24 hours its throwing this error and app is not working ??
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:275:12)
at Protocol.<anonymous> (/opt/node/node_modules/mysql/lib/Connection.js:69:27)
at Protocol.EventEmitter.emit (events.js:95:17)
at Protocol._emitPacket (/opt/node/node_modules/mysql/lib/protocol/Protocol.js:208:8)
at Query.<anonymous> (/opt/node/node_modules/mysql/lib/protocol/Protocol.js:121:12)
at Query.EventEmitter.emit (events.js:95:17)
at Query.start (/opt/node/node_modules/mysql/lib/protocol/sequences/Query.js:29:8)
at Protocol._startSequence (/opt/node/node_modules/mysql/lib/protocol/Protocol.js:262:14)
at Protocol._enqueue (/opt/node/node_modules/mysql/lib/protocol/Protocol.js:134:10)
at Connection.query (/opt/node/node_modules/mysql/lib/Connection.js:165:25)
--------------------
at Protocol._enqueue (/opt/node/node_modules/mysql/lib/protocol/Protocol.js:110:48)
at Connection.query (/opt/node/node_modules/mysql/lib/Connection.js:165:25)
at Object.query (/opt/node/api/database.js:78:16)
at Object.Wait.applyAndWait (/opt/node/node_modules/wait.for/waitfor.js:45:12)
at Object.Wait [as for] (/opt/node/node_modules/wait.for/waitfor.js:61:21)
at exports.getStories (/opt/node/api/stories.js:37:23)
at /opt/node/node_modules/wait.for/waitfor.js:15:31
Error: No default engine was specified and no extension was provided.
at new View (/opt/node/node_modules/express/lib/view.js:41:42)
at Function.app.render (/opt/node/node_modules/express/lib/application.js:486:12)
at ServerResponse.res.render (/opt/node/node_modules/express/lib/response.js:798:7)
at Object.errorHandler [as handle] (/opt/node/app.js:29:7)
at next (/opt/node/node_modules/express/node_modules/connect/lib/proto.js:188:17)
at Object.clientErrorHandler [as handle] (/opt/node/app.js:23:5)
at next (/opt/node/node_modules/express/node_modules/connect/lib/proto.js:188:17)
at Object.logErrors [as handle] (/opt/node/app.js:16:3)
at next (/opt/node/node_modules/express/node_modules/connect/lib/proto.js:188:17)
at next (/opt/node/node_modules/e
xpress/node_modules/connect/lib/proto.js:190:11
Dont know where I am wrong
Thanks in advance