Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fastify v3 compatibility #36

Merged
merged 6 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Request Tracer - Express & Koa middlewares and Fastify & Hapi plugins for CLS-ba

Automatically generates a UUID V1 value as the id for each request and stores it in `AsyncLocalStorage` (CLS core API, see [this blog post](https://itnext.io/one-node-js-cls-api-to-rule-them-all-1670ac66a9e8)). Optionally, if the request contains `X-Request-Id` header, uses its value instead. Allows to obtain the generated request id anywhere in your routes later and use it for logging or any other purposes.

Tested and works fine with Express v4, Fastify v2, Koa (both v1 and v2), and Hapi v18.
Tested and works fine with Express v4, Fastify v2 and v3, Koa v1 and v2, and Hapi v18.
SimenB marked this conversation as resolved.
Show resolved Hide resolved

## Supported Node.js versions

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"@hapi/hapi": "^19.1.1",
"coveralls": "^3.1.0",
"express": "^4.17.1",
"fastify": "^2.14.1",
"fastify": "^3.2.1",
"fastifyv2": "npm:fastify@^2.14.1",
"jest": "^26.0.1",
"koa": "^2.12.0",
"koav1": "npm:koa@^1.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/rtracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const fastifyPlugin = (fastify, options, next) => {
requestId = requestId || uuidv1()

als.run(requestId, () => {
wrapHttpEmitters(request.raw, reply.res)
wrapHttpEmitters(request.raw, reply.raw || reply.res)
done()
})
})
Expand Down
Loading