jeromemacias / fastify-xray Goto Github PK
View Code? Open in Web Editor NEWFastify plugin for AWS XRay recording
License: MIT License
Fastify plugin for AWS XRay recording
License: MIT License
Is there any chance that this can be published? Currently running a modified version of this library as downloaded from NPM and see you've made almost the same changes on master.
Library versions where error is encountered
Error
~/node_modules/aws-xray-sdk-core/lib/utils.js:19
var stat = status.toString();
^
TypeError: Cannot read property 'toString' of undefined
at Object.getCauseTypeFromHttpStatus (~/node_modules/aws-xray-sdk-core/lib/utils.js:19:23)
at Object.fastifyXrayOnResponse (~/node_modules/fastify-xray/plugin.js:84:33)
at onResponseIterator (~/node_modules/fastify/lib/reply.js:502:10)
at next (~/node_modules/fastify/lib/hooks.js:70:20)
at hookRunner (~/node_modules/fastify/lib/hooks.js:84:3)
at ServerResponse.onResFinished (~/node_modules/fastify/lib/reply.js:485:7)
at ServerResponse.emit (events.js:203:15)
at ServerResponse.EventEmitter.emit (domain.js:448:20)
at ServerResponse.emitted (~/node_modules/emitter-listener/listener.js:134:21)
at onFinish (_http_outgoing.js:671:10)
at process._tickCallback (internal/process/next_tick.js:61:11)
From initial investigation, this is because [email protected] does not yet have the getter for statusCode
. This results in fastify-xray/plugin.js:84:33 to pass undefined to getCauseTypeFromHttpStatus
node_modules/fastify-xray/plugin.js
const cause = AWSXRay.utils.getCauseTypeFromHttpStatus(reply.statusCode) // reply doesn't have a statusCode getter/property as of [email protected]
node_modules/aws-xray-sdk-core/lib/utils.js
getCauseTypeFromHttpStatus: function getCauseTypeFromHttpStatus(status) {
var stat = status.toString();
if (stat.match(/^[4][0-9]{2}$/) !== null)
return 'error';
else if (stat.match(/^[5][0-9]{2}$/) !== null)
return 'fault';
}
Quick workaround that I did is to inject a getter for this:
if (!Reply.prototype.statusCode) {
Object.defineProperty(Reply.prototype, 'statusCode', {
get: function() {
return this.res.statusCode
}
})
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.