balderdashy/sails · error
Cannot call res.render() - `req._sails` was not attached
Error message
Cannot call res.render() - `req._sails` was not attached
What it means
Error "Cannot call res.render() - `req._sails` was not attached" thrown in balderdashy/sails.
Source
Thrown at lib/router/res.js:321
// (Otherwise, we can just rely on `send` to do that for us.)
if (_.isString(data)) {
data = JSON.stringify(data);
res.set('content-type', 'application/json');
}
return res.status(res.statusCode || 200).send(data);
};
// res.render()
res.render = res.render || function _renderShim (relativeViewPath, locals, cb) {
if (_.isFunction(locals)) {
cb = locals;
locals = {};
}
try {
if (!req._sails) {
throw new Error('Cannot call res.render() - `req._sails` was not attached');
}
if (!req._sails.renderView) {
throw new Error('Cannot call res.render() - `req._sails.renderView` was not attached (perhaps `views` hook is not enabled?)');
}
res.set('content-type', 'text/html');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO:
// Instead of this shim, turn `sails.renderView` into something like
// `sails.hooks.views.render()`, and then call it.
throw flaverr({statusCode: 501}, new Error('Not implemented in core yet'));
//
// Instead, do something like the following:
// ```
// var html;
// // ...
// if (cb) {View on GitHub (pinned to 7b76422cc2)
When it happens
Trigger: Thrown at lib/router/res.js:321 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/cb2e74208ce507c2.
Report an issue: GitHub.