"Error: stream encoding should not be set"
opened this issue · comments
Throwing this error from line 48 of index.js (raw-body version 1.1.1):
Error: stream encoding should not be set at makeError (/my/app/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:132:15) at /my/app/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:48:17 at process._tickCallback (node.js:415:13)
Value of stream.encoding is undefined, rather than null, which it is expecting. Updated line to read the following and everything seems to work great:
if (state && state.encoding !== null && state.encoding != undefined)
ohhhhh that makes sense.
i'll do that, but why do you know why it is set as undefined?
Not sure - it's being used by ExpressJS like that. I'm just including express in my app.
what platform are you on? i'm bumping connect and express now
SunOS 5.11 i86pc i386 i86pc Solaris
oh, something i know nothing about.
It's an instance on Joyent
fixed and pushed to connect/express. if you guys can figure out when it's set as undefined
, that would be great! i'll leave this issue open just for that.
Thanks! I did notice that this seems to only be an issue with an https server. When I run in an environment with SSL off, there are no problems.
Seeing the same issue here, running Node v0.10.4 on Windows, with iisnode as the front-end. It happens only on POST requests (with a body to parse). The incoming request is coming in via SSL, though the SSL terminates at IIS and it is passed to iisnode as a HTTP request (with X-Forwarded-For headers). My code never calls req.setEncoding()
-- though I can't vouch for express/connect middleware that may run before mine.
Did the latest version fix your problem?
Fixed it for me.
Yes, it appears to be fixed in express 3.4.6/raw-body 1.1.2.
so i guess it's something with SSL. i'll keep this issue open until i (or someone else :D) adds a test for it.
Updating from express 3.4.5 to 3.4.7 solved this issue for me as well. Just wanted to add that in my case everything was fine when running locally on my Mac, but I started getting the error once I published to Windows Azure.
In case it's of any use, the project I am working on is located here on GitHub https://github.com/platta/picstream (if you view any of my code, don't judge me too harshly - I'm new to node.js :) ).
So the official answer is there was no state.encoding
property until node.js v0.10.6 (added in commit nodejs/node-v0.x-archive@bdb78b9). Thus state.encoding
was always undefined
before that version :)