Browse Source

Fix errorMiddleware to prevent "TypeError: res.writeHead is not a function" (#3913)

* Fix errorMiddleware

* Add "eslint-disable-line no-unused-vars"
pull/4/head
Takuya Yoshida 4 years ago
committed by Eugen Rochko
parent
commit
0c44316b22
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      streaming/index.js

+ 1
- 1
streaming/index.js View File

@ -242,7 +242,7 @@ const startWorker = (workerId) => {
accountFromRequest(req, next);
};
const errorMiddleware = (err, req, res) => {
const errorMiddleware = (err, req, res, next) => { // eslint-disable-line no-unused-vars
log.error(req.requestId, err.toString());
res.writeHead(err.statusCode || 500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: err.statusCode ? err.toString() : 'An unexpected error occurred' }));

Loading…
Cancel
Save