javascript - Koa inexplicably reports ctx.onerror is not a function. What is the situation?
巴扎黑
巴扎黑 2017-06-12 09:28:10
0
1
1101

Whenever I open safiri locally, the local koa project will crash. I don’t know what’s going on. .

Listening on:8000
/Users/lmn/project/u-pain-i-guess/node_modules/koa/lib/application.js:133
      const onerror = err => ctx.onerror(err);
                                 ^

TypeError: ctx.onerror is not a function
    at Array.onerror (/Users/lmn/project/u-pain-i-guess/node_modules/koa/lib/application.js:133:34)
    at listener (/Users/lmn/project/u-pain-i-guess/node_modules/on-finished/index.js:169:15)
    at onFinish (/Users/lmn/project/u-pain-i-guess/node_modules/on-finished/index.js:100:5)
    at callback (/Users/lmn/project/u-pain-i-guess/node_modules/ee-first/index.js:55:10)
    at ServerResponse.onevent (/Users/lmn/project/u-pain-i-guess/node_modules/ee-first/index.js:93:5)
    at emitNone (events.js:91:20)
    at ServerResponse.emit (events.js:188:7)
    at onFinish (_http_outgoing.js:592:10)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

The above string is the error message, server listen is on port 8000
I tried to add it in the code

app
  .use(bodyParser)
  .use(router.routes())
  .use(router.allowedMethods())
  .on('error', console.error)

app.onerror = console.error

Still like this. .
Please give me a big answer.

巴扎黑
巴扎黑

reply all(1)
给我你的怀抱

You should take out the code in app.js and take a look, otherwise no one will be able to directly locate the problem. If you get an error like this, it may be that some logic in the middle has rewritten app.context.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template