diff --git a/lib/application.js b/lib/application.js index 1b1766d..866a1b8 100644 --- a/lib/application.js +++ b/lib/application.js @@ -113,7 +113,7 @@ app.use = function(fn){ app.callback = function(){ var mw = [respond].concat(this.middleware); var gen = compose(mw); - var fn = co(gen); + var fn = co.wrap(gen); var self = this; if (!this.listeners('error').length) this.on('error', this.onerror); @@ -122,7 +122,7 @@ app.callback = function(){ res.statusCode = 404; var ctx = self.createContext(req, res); onFinished(res, ctx.onerror); - fn.call(ctx, ctx.onerror); + fn.call(ctx).catch(ctx.onerror); } }; diff --git a/package.json b/package.json index 5466584..c0f2a37 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "dependencies": { "accepts": "^1.1.0", - "co": "^3.1.0", + "co": "^4.0.0", "content-disposition": "~0.5.0", "cookies": "~0.5.0", "debug": "*",