balderdashy/sails · error
`statusCode` must be passed to res.writeHead().
Error message
`statusCode` must be passed to res.writeHead().
What it means
Error "`statusCode` must be passed to res.writeHead()." thrown in balderdashy/sails.
Source
Thrown at lib/router/res.js:114
// ```
// var reasonPhrase = (function(){
// if (arguments[2] && _.isString(arguments[1])) {
// return arguments[1];
// }
// return undefined;
// })();
// ```
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var newHeaders = (function (){
if (arguments[2] && _.isObject(arguments[2])) {
return arguments[2];
}
return arguments[1];
})();
if (!statusCode) {
throw new Error('`statusCode` must be passed to res.writeHead().');
}
// Set status code
res.statusCode = statusCode;
// Ensure `._headers` have been merged into `.headers`
_.extend(res.headers, res._headers);
if (newHeaders) {
if (!_.isObject(newHeaders)) {
throw new Error('`headers` must be passed to res.writeHead() as an object. Got: '+util.inspect(newHeaders, false, null));
}
// Set new headers
_.extend(res.headers, newHeaders);
}
// Set status code and headers on the `_clientRes` stream so they are accessible
// to the provider of that stream.
// (this has to happen in `send()` because the code/headers might have just changed)View on GitHub (pinned to 7b76422cc2)
When it happens
Trigger: Thrown at lib/router/res.js:114 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01).
Data as JSON: /api/errors/790996ebd9eea72f.
Report an issue: GitHub.