Closed NoumanSaleem closed 9 years ago
Would you be able to post a standard-formatted stack trace or code to reproduce? Either of those two would help a lot :)
@dougwilson wish I had some more context around this. Unfortunately just have the error itself. I'll be doing some more digging into reproducing this. Hope the slightly better (maybe not) formatting helps :)
It happened in an express web application (express v4.8.7)
thanks!
trace=[
column=54,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=null,
line=81,
method=null,
native=false,
column=null,
file=null,
function=Array.every,
line=null,
method=every,
native=true,
column=14,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=specify,
line=80,
method=null,
native=false,
column=12,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=accepted.map.filter.sort.s,
line=48,
method=map.filter.sort.s,
native=false,
column=null,
file=null,
function=Array.map,
line=null,
method=map,
native=true,
column=20,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=getMediaTypePriority,
line=47,
method=null,
native=false,
column=21,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=provided.map.filter.sort.pa,
line=101,
method=map.filter.sort.pa,
native=false,
column=null,
file=null,
function=Array.map,
line=null,
method=map,
native=true,
column=21,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js,
function=preferredMediaTypes,
line=100,
method=null,
native=false,
column=12,
file=/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/negotiator.js,
function=Negotiator.(anonymousfunction),
line=26,
method=(anonymousfunction),
native=false
],
stack=[
TypeError: Cannotcallmethod'toLowerCase'ofundefined,
at/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 81: 54,
atArray.every(native),
atspecify(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 80: 14),
ataccepted.map.filter.sort.s(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 48: 12),
atArray.map(native),
atgetMediaTypePriority(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 47: 20),
atprovided.map.filter.sort.pa(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 101: 21),
atArray.map(native),
atpreferredMediaTypes(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js: 100: 21),
atNegotiator.(anonymousfunction)(/app/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/negotiator.js: 26: 12)
]
I think this error is because you are adding an enumerable property on Object.prototype
, which will wreck havoc in all sorts of weird places. Would you be willing to show the output of the following within your application's code?
console.dir(Object.prototype)
Nevermind, I have determined the cause and it's from an invalid media type most likely. Example: text/html; foo
(foo
at the end is invalid because it needs to be a key value pair).
OK, so what I believe was causing your issue should be resolved now. I'll issue out a new version of this module and accepts
module and you should be able to npm update
your express install to pull it in.
@dougwilson really appreciate the quick response on this and your work on express!
You're welcome :) And let me know if you're still seeing this error pop up, even after updating accepts
to 1.1.2, since I fixed a error with the same stack trace you provided, but cannot be 100% sure it fixed your issue :)
Taking a look at our server logs and see this error pop up quite a bit: