ExpressJS ошибка TypeError: n.status не функция действительно запускает меня через звонок? - PullRequest
0 голосов
/ 25 апреля 2020

У меня дьявол времени, чтобы выяснить, что здесь происходит. Не происходит локально или в стадии подготовки, но я вижу тысячи в день в производстве .... Я присваиваю этот код, и я не могу найти, откуда исходит эта ошибка TypeEr .. так как все сводится к Prod .., но даже stacktrack? ..... Есть мысли или подсказки?

 insertId: "**********"  
 labels: {
  k8s-pod/app: "client"   
  k8s-pod/pod-template-hash: "*******"   
 }
 logName: "projects/******/logs/stderr"  
 receiveTimestamp: "2020-04-25T06:12:40.927238528Z"  
 resource: {
  labels: {
   cluster_name: "jv-cluster"    
   container_name: "client"    
   location: "us-west1"    
   namespace_name: "default"    
   pod_name: "client-*********"    
   project_id: "************"    
  }
  type: "k8s_container"   
 }
 severity: "ERROR"  
 textPayload: "TypeError: n.status is not a function
    at /usr/src/app/build/server.js:1:1099439
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:91:12)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at /usr/src/app/build/server.js:1:1098712
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at cookieParser (/usr/src/app/node_modules/cookie-parser/index.js:57:14)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at Domain.next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Domain.run (domain.js:369:14)
    at Bugsnag.requestHandler (/usr/src/app/node_modules/bugsnag/lib/bugsnag.js:208:16)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at expressInit (/usr/src/app/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at query (/usr/src/app/node_modules/express/lib/middleware/query.js:45:5)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3)
    at Function.handle (/usr/src/app/node_modules/express/lib/application.js:174:10)
    at Server.app (/usr/src/app/node_modules/express/lib/express.js:39:9)
    at Server.emit (events.js:197:13)
    at Server.EventEmitter.emit (domain.js:481:20)
    at parserOnIncoming (_http_server.js:680:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)

ЗДЕСЬ МОЙ СЕРВЕР-ФАЙЛ ::

import '@babel/polyfill';
import Bugsnag from 'src/utils/Bugsnag';
import Express from 'express';
import path from 'path';
import cookieParser from 'cookie-parser';
import handleRender from './handleRender'; // SSR
import renderStackTrace from './renderStackTrace';
import renderErrorBody from './renderErrorBody';
import validateLocationPage from './validateLocationPage';

Bugsnag.init();
const app = new Express();
app.use(Bugsnag.instance.requestHandler);
app.use(cookieParser());

if (process.env.NODE_ENV !== 'development') {
  app.use('/client-assets', Express.static('build/public'));
  app.get('/sw.js', (req, res) => {
    res.set({
      'Content-Type': 'application/javascript',
    });
    res.status(200);
    res.sendFile(path.resolve('build', 'public', 'sw.js'), function resolve(err) {
      // TODO: remove console logs
      if (err) {
        console.log(err); // eslint-disable-line
        res.status(err.status).end();
      } else {
        console.log('sent sw'); // eslint-disable-line
      }
    });
  });
} else {
  app.use('/client-assets', Express.static('dev/build'));
  app.get('/client-assets/dll/validateNextState.js.map', (req, res) => {
    res.write('');
    res.end();
  });
}

app.use((req, res, next) => {
  next();
});

app.get('/jv-clients-health', function sendOk(req, res) {
  res.status(200);
  res.write('OK');
  res.end();
});

app.get('/favic.ico', function sendOk(req, res) {
  res.status(200);
  console.log('favicons failed'); // eslint-disable-line
  res.write('OK');
  res.end();
});

app.get('/us*', validateLocationPage);

app.get('*', handleRender);

app.use(Bugsnag.instance.errorHandler);

app.use(function handleError(err, req, res) {
  // eslint-disable-line
  console.log(err); // eslint-disable-line
  res.status(500);
  if (process.env.NODE_ENV === 'development') {    
    res.send(renderStackTrace(err));
  } else {    
    const errorBody = renderErrorBody({ error: err, code: 500 });
    res.write(errorBody);
    res.end();
  }
});

app.listen(3006, '0.0.0.0', function appListen(err) {
  if (err) {
    console.log(err); // eslint-disable-line
  }
  console.log(
    `\n==> App-Server(${process.env.NODE_ENV}) listening at ${process.env.HOST}:3006`,
  ); // eslint-disable-line
  console.log('NODE_ENV: ', process.env.NODE_ENV);
  console.log('CLIENT_HOST: ', process.env.CLIENT_HOST);
  console.log('PORT: ', process.env.PORT);
  console.log('HOST: ', process.env.HOST);
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...