persvr / persevere-example-wiki

Example wiki built with Persevere 2.0
http://www.persvr.org/
30 stars 17 forks source link

Response data crashes node #8

Open dhalford opened 14 years ago

dhalford commented 14 years ago

I haven't been able to get further down the stack from this but it looks like the page responses are not being templated properly

for each response node is failing at http://github.com/kriszyp/jsgi-node/zipball/v0.2.1!/lib/jsgi-node.js:165:18 forEachResult = data.body.forEach( function( chunk ) { response.write( chunk, data.body.encoding || "utf8" ); });

Adding a try/catch around this shows that the problem is that the chunk being passed through is a js object rather than a string. here is the output from each chunk:

chunk 0: <html><body>

chunk 1: { pageName: 'Example' , content: '<p>asdf asdf asdf</p>' , location: undefined } { message: 'first argument must be a string, Array, or Buffer' , stack: [Getter/Setter] }

chunk 2: <body></html>

TypeError: first argument must be a string, Array, or Buffer at ServerResponse.write (http:488:11) at jar:http://github.com/kriszyp/jsgi-node/zipball/v0.2.1!/lib/jsgi-node.js:165:18 at Object.forEach (eval at (jar:http://github.com/dmachi/templify/zipball/master!/lib/template.js:32:12)) at jar:http://github.com/kriszyp/pintura/zipball/v0.2.2!/lib/media/html.js:66:24 at jar:http://github.com/kriszyp/promised-io/zipball/v0.2.1!/lib/promise.js:320:10 at jar:http://github.com/kriszyp/pintura/zipball/v0.2.2!/lib/media/html.js:65:13 at notify (jar:http://github.com/kriszyp/promised-io/zipball/v0.2.1!/lib/promise.js:162:22) at [object Object].then (jar:http://github.com/kriszyp/promised-io/zipball/v0.2.1!/lib/promise.js:215:4) at jar:http://github.com/kriszyp/promised-io/zipball/v0.2.1!/lib/promise.js:314:20 at Object.forEach (jar:http://github.com/kriszyp/pintura/zipball/v0.2.2!/lib/media/html.js:64:12)

dhalford commented 14 years ago

Adjusting templify to return the template path with '.template' fixes the problem