Maximum call stack size exceeded
See original GitHub issueHi,
I keep getting this error when I call this.render using koa-jade:
server error [RangeError: Maximum call stack size exceeded] { request: { method: ‘GET’, url: ‘/daniel’, header: { ‘x-real-ip’: ‘10.211.55.2’, ‘x-forwarded-for’: ‘10.211.55.2’, host: ‘docs.sandbox.local:80’, ‘x-nginx-proxy’: ‘true’, connection: ‘close’, ‘cache-control’: ‘max-age=0’, accept: ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8’, ‘upgrade-insecure-requests’: ‘1’, ‘user-agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36’, ‘accept-encoding’: ‘gzip, deflate, sdch’, ‘accept-language’: ‘en-US,en;q=0.8’, cookie: ‘_ga=GA1.2.1728672733.1439768627’ } }, response: { status: 200, message: ‘OK’, header: { ‘access-control-allow-origin’: ‘*’, ‘access-control-allow-methods’: ‘GET,HEAD,PUT,POST,DELETE’, ‘cache-control’: ‘no-cache’, ‘content-type’: ‘text/html; charset=utf-8’, ‘content-length’: ‘19’ } }, app: { subdomainOffset: 2, env: ‘development’ }, originalUrl: ‘/daniel’, req: ‘<original node req>’, res: ‘<original node res>’, socket: ‘<original node socket>’ }
This is the code:
‘use strict’; ‘use esnext’;
function *base(route, next) { yield this.render(‘base’, { title: ‘Docs’, styles: [ // materialize ‘/materialize.min.css’,
// material icons
'/css/materialdesignicons.min.css',
// graphkit
'/app.css'
],
vendors: [
// jquery
'/jquery.min.js',
// angular
'/angular.min.js',
'/angular-aria.min.js',
'/angular-route.min.js',
// materialize
'/materialize.min.js',
// d3
'/d3.min.js'
],
packages: [
// app
'/app.js',
'/auth.js',
'/connect.js',
'/http.js',
'/router.js'
]
}, true);
if (undefined !== next) {
yield next;
}
}
function *index(route, next) { yield this.render(‘routes/index’, {}, true); }
function *profile(route, next) { yield this.render(‘routes/profile’, {}, true); }
function *error(route, next) { yield this.render(‘routes/error404’, {}, true); }
module.exports = function(app) { const koaRoute = require(‘koa-route’); const koaJade = require(‘koa-jade’); const jade = new koaJade({ viewPath: __dirname + ‘/src/views’, debug: ‘development’ == app.env, pretty: ‘development’ == app.env, compileDebug: ‘development’ == app.env, locals: { title: ‘Docs’ }, basedir: ‘/’, noCache: true, helperPath: [ //‘path/to/jade/helpers’, //{ random: ‘path/to/lib.js’ }, ] });
app.use(jade.middleware);
// base
app.use(koaRoute.get('/', base));
app.use(koaRoute.get('/a/welcome', base));
app.use(koaRoute.get('/:username', base));
// index
app.use(koaRoute.get('/route/index', index));
// profile
app.use(koaRoute.get('/route/profile', profile));
};
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
@ladytellur
koa-pug
supportskoa@1
andkoa@2
, just usethis.render()
withoutyield
:@chrisyip some of us just wants to use koa@1 until async/await will become native in stable Node version