在我们的后端服务器上添加 elastic-apm-node 后,我们每天会收到数百次以下错误。谁能建议可能导致这种情况的原因?
我们看到的错误是这样的:
{ SyntaxError: Unexpected token " in JSON at position 0
at JSON.parse (<anonymous>)
at createStrictSyntaxError (/usr/src/app/node_modules/body-parser/lib/types/json.js:158:10)
at parse (/usr/src/app/node_modules/body-parser/lib/types/json.js:83:15)
at /usr/src/app/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/usr/src/app/node_modules/raw-body/index.js:224:16)
at done (/usr/src/app/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/usr/src/app/node_modules/raw-body/index.js:273:7)
at IncomingMessage.elasticAPMCallbackWrapper (/usr/src/app/node_modules/elastic-apm-node/lib/instrumentation/index.js:309:27)
at IncomingMessage.emit (events.js:203:15)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
expose: true,
statusCode: 400,
status: 400,
body:
'"<html>\\r\\n<head><title>502 Bad Gateway</title></head>\\r\\n<body bgcolor=\\"white\\">\\r\\n<center><h1>502 Bad Gateway</h1></center>\\r\\n</body>\\r\\n</html>\\r\\n"',
type: 'entity.parse.failed',
traceId: 'ERR-344BC630',
[Symbol(ElasticAPMErrorReported)]: true }
我认为我们运行 node v10.x 但我不确定。
该服务是建立在feathersJS 之上的,而feathersJS 又是建立在Express 之上的。
我们像这样启动 APM:
require("elastic-apm-node").start({
serviceName: "serviceX",
serverUrl: "http://xxx:8200"
});
package.json 中列出的依赖项是:
"dependencies": {
"@sendgrid/mail": "^6.0.0",
"advisory-lock": "^1.1.1",
"aws-sdk": "^2.265.1",
"axios": "^0.19.0",
"body-parser": "^1.18.3",
"check-types": "^7.3.0",
"compression": "^1.7.2",
"config": "^1.26.2",
"connect-history-api-fallback": "^1.3.0",
"cors": "^2.8.4",
"cron": "^1.3.0",
"elastic-apm-node": "^3.2.0",
"elasticsearch": "^16.5.0",
"feathers": "^2.2.4",
"feathers-authentication": "^1.3.1",
"feathers-authentication-hooks": "^0.3.0",
"feathers-authentication-jwt": "^0.3.2",
"feathers-authentication-local": "^0.4.4",
"feathers-configuration": "^0.4.1",
"feathers-errors": "^2.9.1",
"feathers-hooks": "^2.0.2",
"feathers-hooks-common": "^3.7.1",
"feathers-rest": "^1.8.1",
"feathers-sequelize": "^2.3.0",
"feathers-socketio": "^2.0.1",
"gm": "^1.23.1",
"heapdump": "^0.3.15",
"helmet": "^3.20.0",
"i18n": "^0.8.3",
"jws": "^3.1.5",
"lodash": "^4.17.15",
"logstash-client": "^1.1.1",
"moment": "^2.22.2",
"moment-timezone": "^0.5.23",
"multer": "^1.3.0",
"mustache": "^2.3.0",
"node-rdkafka": "^2.7.1-2",
"node-uuid": "^1.4.8",
"passport-saml": "^0.33.0",
"pg": "^6.4.2",
"prom-client": "^11.2.1",
"redis": "^2.8.0",
"sequelize": "^4.38.0",
"serve-favicon": "^2.5.0",
"util": "^0.10.3",
"uuid": "^3.1.0",
"winston": "^2.3.1"
},