[breaking change] don't bind onerror to context (#800)
This commit is contained in:
parent
614b4e1ad7
commit
4338cb6c14
2 changed files with 4 additions and 4 deletions
|
@ -131,8 +131,9 @@ module.exports = class Application extends Emitter {
|
|||
return (req, res) => {
|
||||
res.statusCode = 404;
|
||||
const ctx = this.createContext(req, res);
|
||||
onFinished(res, ctx.onerror);
|
||||
fn(ctx).then(() => respond(ctx)).catch(ctx.onerror);
|
||||
const onerror = err => ctx.onerror(err);
|
||||
onFinished(res, onerror);
|
||||
fn(ctx).then(() => respond(ctx)).catch(onerror);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -152,7 +153,6 @@ module.exports = class Application extends Emitter {
|
|||
request.ctx = response.ctx = context;
|
||||
request.response = response;
|
||||
response.request = request;
|
||||
context.onerror = context.onerror.bind(context);
|
||||
context.originalUrl = request.originalUrl = req.url;
|
||||
context.cookies = new Cookies(req, res, {
|
||||
keys: this.keys,
|
||||
|
|
|
@ -164,7 +164,7 @@ module.exports = {
|
|||
// stream
|
||||
if ('function' == typeof val.pipe) {
|
||||
onFinish(this.res, destroy.bind(null, val));
|
||||
ensureErrorHandler(val, this.ctx.onerror);
|
||||
ensureErrorHandler(val, err => this.ctx.onerror(err));
|
||||
|
||||
// overwriting
|
||||
if (null != original && original != val) this.remove('Content-Length');
|
||||
|
|
Loading…
Reference in a new issue