status
stringclasses
1 value
repo_name
stringlengths
9
24
repo_url
stringlengths
28
43
issue_id
int64
1
104k
updated_files
stringlengths
8
1.76k
title
stringlengths
4
369
body
stringlengths
0
254k
βŒ€
issue_url
stringlengths
37
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
unknown
language
stringclasses
5 values
commit_datetime
unknown
closed
fastify/fastify
https://github.com/fastify/fastify
1,538
["fastify.d.ts", "test/types/index.ts"]
`this` is not typed in RequestHandler
Before you submit an issue we recommend you drop into the [Gitter community](https://gitter.im/fastify) or [Fastify Help](https://github.com/fastify/help) and ask any questions you have or mention any problems you've had getting started with Fastify. **Please read this entire template before posting any issue. If you ignore these instructions and post an issue here that does not follow the instructions, your issue might be closed, locked, and assigned the `missing discussion` label.** ## πŸ› Bug Report A clear and concise description of what the bug is. ## To Reproduce Steps to reproduce the behavior: Paste your code here: ```ts fastify.get('/api/xx', function(req, res) { this. // no completion and Type checker complains. }) ``` ## Expected behavior A clear and concise description of what you expected to happen. Paste the results here: ```ts fastify.get('/api/xx', function(req, res) { this. // this points to FastifyInstance }) ``` ## Your Environment - *node version*: 6,8,10 - *fastify version*: >=1.0.0 - *os*: Mac, Windows, Linux - *any other relevant information*
https://github.com/fastify/fastify/issues/1538
https://github.com/fastify/fastify/pull/1539
767923b3aba0e0fea57758f7ff408c616bfdee66
eafb2fb87b4b5b281b7a13a85f42114790e04e67
"2019-03-15T02:54:39Z"
javascript
"2019-03-20T18:51:09Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,537
["test/helper.js"]
Test failures on CITGM
Currently a few fastify tests fail on CITGM. They do not seem to be related to the latest changes in Node.js core, so I guess they might be flaky tests in fastify? It would be great if that could be verified right quick as I am planning on releasing v11.12.0 in a few hours. See https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1766/nodes=osx1011/testReport/junit/(root)/citgm/fastify_v2_0_1/ and https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1766/nodes=win-vs2017/testReport/junit/(root)/citgm/fastify_v2_0_1/
https://github.com/fastify/fastify/issues/1537
https://github.com/fastify/fastify/pull/1545
9c3f03f1aebd68bdd4500c0d413f72dbde5ee579
b48a6059d44092c643ccdbbbc2cf5e136e8226cf
"2019-03-14T15:50:51Z"
javascript
"2019-03-16T11:34:53Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,512
["lib/validation.js", "test/validation-error-handling.test.js"]
Schema errors text can have `undefined` in the output
https://github.com/fastify/fastify/blob/f5d1027f385df693c74a51833b51cfebe25e2241/lib/validation.js#L154 `errors` as JSON: ```json [{"message":"foo is required.","path":["foo"],"type":"any.required","context":{"key":"foo","label":"foo"}}] ``` `options` as JSON: ```json {"dataVar":"body"} ``` The resulting string from this function with that given input: ```JSON "bodyundefined foo is required." ```
https://github.com/fastify/fastify/issues/1512
https://github.com/fastify/fastify/pull/1513
b4560139a74d5a40c58d30d1bd7dd2dc21a1b153
73e9e05dc619e98163f127c34d045762d4a483c4
"2019-03-06T15:26:25Z"
javascript
"2019-03-07T11:23:23Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,510
["CONTRIBUTING.md"]
Process for dismissing a collaborator
Hello everyone! We do have a [policy](https://github.com/fastify/fastify/blob/master/CONTRIBUTING.md) for inviting members to join the team, but we do not have one for dismissing members and make them emeritus. Do you have any proposal, or do you know a method that is already working well in other organizations? Any feedback is more than welcome!
https://github.com/fastify/fastify/issues/1510
https://github.com/fastify/fastify/pull/1646
0ce4f0d245388179049392b44360327151eac66e
a210899eb32ddc95b5b70b5c5e0119c4e6efed3f
"2019-03-06T09:57:23Z"
javascript
"2019-05-16T06:02:29Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,491
["lib/schemas.js", "test/shared-schemas.test.js"]
Using named schema in items field breaks schema validation
## πŸ› Bug Report Using some named schema as `items` in other schema cause exception when using first schema ## To Reproduce Steps to reproduce the behavior: Add schema with simple item. Then add schema for items array and use first schema `$id` in `items`. Then use the first schema in some route. Paste your code here: ```js const fastify = require('fastify')(); (async () => { const name = 'item'; const item = {type: 'object', properties: {foo: {type: 'string'}}}; fastify.addSchema({ $id: `${name}`, ...item, }); fastify.addSchema({ $id: `${name}List`, type: 'array', items: `${name}#`, }); fastify.get( '/', { schema: { response: { 200: `${name}#`, }, }, }, async (req, res) => { return {}; } ); await fastify.ready(); await fastify.listen(3000); console.log('app listens'); })(); ``` ``` (node:21665) UnhandledPromiseRejectionWarning: Error: schema is invalid: data.items should be object,boolean, data.items should be array, data.items should match some schema in anyOf at Ajv.validateSchema (/tmp/xxx/node_modules/ajv/lib/ajv.js:177:16) at Ajv._addSchema (/tmp/xxx/node_modules/ajv/lib/ajv.js:306:10) at Ajv.addSchema (/tmp/xxx/node_modules/ajv/lib/ajv.js:136:29) at Object.keys.forEach.key (/tmp/xxx/node_modules/fast-json-stringify/index.js:937:11) at Array.forEach (<anonymous>) at isValidSchema (/tmp/xxx/node_modules/fast-json-stringify/index.js:936:33) at build (/tmp/xxx/node_modules/fast-json-stringify/index.js:39:3) at getValidatorForStatusCodeSchema (/tmp/xxx/node_modules/fastify/lib/validation.js:13:10) at /tmp/xxx/node_modules/fastify/lib/validation.js:19:21 at Array.reduce (<anonymous>) ``` ## Expected behavior No exception thrown. ## Your Environment - *node version*: 11 - *fastify version*: 2.0.0 - *os*: Mac, Linux
https://github.com/fastify/fastify/issues/1491
https://github.com/fastify/fastify/pull/1496
563926f3d7eb8a03a32813ac84f4cdb5bddcf911
9398dfab9ed46f262e32002ab75ac7b264e57a21
"2019-02-28T11:16:13Z"
javascript
"2019-03-02T17:10:31Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,475
["fastify.js", "lib/fourOhFour.js", "lib/middleware.js", "lib/route.js"]
Split up fastify.js
Currently the `fastify.js`Β  file is very big, and it contains several concerns, all mixed together. Maybe it's time we split it up into tinier files that are easier to read and contribute to.
https://github.com/fastify/fastify/issues/1475
https://github.com/fastify/fastify/pull/1625
d377ebe460bd045535ba272a3dfa9c44bf8ee763
9e65ca4ed62fed5239b0719c961c79c0c073dd8b
"2019-02-24T18:44:15Z"
javascript
"2019-05-19T21:09:40Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,441
["docs/Validation-and-Serialization.md", "fastify.js", "lib/schemas.js", "lib/validation.js", "test/shared-schemas.test.js"]
Shared schema referenced by validator
## πŸ› Bug Report Now if I set a JSON Schema for validating the input of a route, defining a `$ref` relative to a shared schema, the fastify server doesn't start returning an error: > { [Error: can't resolve reference http://example.com/ref-to-external-validator.json# from id #] message: 'can\'t resolve reference http://example.com/ref-to-external-validator.json# from id #', missingRef: 'http://example.com/ref-to-external-validator.json', missingSchema: 'http://example.com/ref-to-external-validator.json' } ## To Reproduce [Here a GIST with the demo code](https://gist.github.com/Eomm/2e6e01a02e06d34256c767e076b5562f#file-test-validator-ref-id) ## Expected behavior The validator must consider the schema added via `addSchema` to compile the `body | querystringSchema | paramsSchema | headersSchema` Paste the results here: I have tried a brutal solution to apply in `lib\validation.js` that works -for AJV-: ```js if (context.schema.body) { Object.values(schemas.getSchemas()).forEach(_ => globalAjv.addSchema(_)) context[bodySchema] = compile(context.schema.body) } ``` Since the `buildSchemaCompiler` must return a function, I can't find a way to use the `addSchema` function in the `compile` parameter. So I would to return a function that accept the schema as first parameter and the array of other external/support schemas as second param. This shouldn't have impact to actual usage of the feature The other idea is to move the building of the schema just before this line: https://github.com/fastify/fastify/blob/c9f6ba92788c1ef70fb24ab4bb34a5d58f433dde/fastify.js#L639 where I should have already all the shared schemas and I could just add an array parameter with the shared schemas to `buildSchemaCompiler` and the users must only accept or ignore that param. Let me know what do you think Thanks ## Your Environment - *node version*: 10.11 - *fastify version*: >= 2.0.0-rc.6 - *os*: Windows
https://github.com/fastify/fastify/issues/1441
https://github.com/fastify/fastify/pull/1446
4c03ddaf3920ab61e3d8ac5d8f347268fb90cb71
a27850d3f94b6f337e42b524f13356dbd455a48e
"2019-02-07T18:37:06Z"
javascript
"2019-02-23T08:36:46Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,429
["docs/Validation-and-Serialization.md"]
attachValidation document is wrong?
https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md i see "ErrorHandling" section of this document and i'm test by my local environment. in document, write this >If you want to handle errors inside the route, you can specify the attachValidation option for your route. If there is a validation error, the validationError property of the request will contain the Error object with the raw validation result as shown below and attached this code. ```JavaScript const fastify = Fastify() fastify.post('/', { schema, attachValidation: true }, function (req, reply) { if (req.validation) { // `req.validationError.validation` contains the raw validation error reply.code(400).send(req.validationError) } }) ``` but run this code(scheme is customized) in my environment, "req.validation" is every time undefined. so I would like to confirm there, "req.validation" is typo "req.validationError" ? thank you.
https://github.com/fastify/fastify/issues/1429
https://github.com/fastify/fastify/pull/1430
720fb25d4c3f9d994baed344fd6e06545f0bc7d5
3a46235fcdfdb9a338621cf0d4bfb6ef3decbd99
"2019-02-04T05:31:24Z"
javascript
"2019-02-04T08:04:13Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,419
["package.json", "test/shared-schemas.test.js"]
Json schema $ref id
## πŸ› Bug Report Hi, testing the (fluent) json-schema I found that the [id-with-ref](https://json-schema.org/understanding-json-schema/structuring.html#using-id-with-ref) function is broken and return on start: > { [Error: can't resolve reference #address from id #] message: 'can\'t resolve reference #address from id #', missingRef: '#address', missingSchema: '' } ## To Reproduce ```js const fastify = require('./fastify')({ logger: { level: 'debug' } }) const body = { '$schema': 'http://json-schema.org/draft-07/schema#', 'definitions': { '#address': { 'type': 'object', '$id': '#address', 'properties': { 'city': { 'type': 'string' }, 'zipcode': { 'type': 'string' } } } }, 'type': 'object', '$id': 'http://foo/user', 'title': 'My First Fluent JSON Schema', 'description': 'A simple user', 'properties': { 'email': { 'type': 'string', 'format': 'email' }, 'address': { '$ref': '#address' } }, 'required': [ 'email' ] } fastify.post('/', { schema: { body } }, (request, reply) => { reply.send('good') }) fastify.listen(3000).catch(console.log) ``` ## Expected behavior The JSON schema is a valid one and use the `$ref: '#id'` function so the error doen't have to be thrown and the `#address` should be resolved. ## Your Environment - *node version*: 10 - *fastify version*: >= 2.0.0-rc.4 `master branch` - *os*: Windows I would like to work on it πŸ˜ƒ I found that the problem is due to this line for the issue #1043 https://github.com/fastify/fastify/blob/310cb60b439fb363b28d42eb2e0f351447c7f11b/lib/schemas.js#L83 -if I comment it the example works fine, but the test fails-
https://github.com/fastify/fastify/issues/1419
https://github.com/fastify/fastify/pull/1433
946d9f84afb202e49c89d8511be14e9bf4740a1b
c9f6ba92788c1ef70fb24ab4bb34a5d58f433dde
"2019-01-30T20:36:13Z"
javascript
"2019-02-06T00:32:13Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,410
["docs/Validation-and-Serialization.md", "lib/schemas.js", "lib/validation.js", "test/shared-schemas.test.js"]
Serialization references not resolved
## πŸ› Bug Report References for validation can be added using the `addSchema` method, so in our JSON schemas we can safely use `$ref` to reference them. However, when trying to do the same for the serialization using `fast-json-stringify` I get the following error: ``` Error: schema is invalid: data.items.$ref should be string, data.items should be array, data.items should match some schema in anyOf ``` Reading up on the documentation (https://github.com/fastify/fast-json-stringify#ref) it seems that external definitions need to be passed as an option, so I was wondering if the `addSchema` function would not already do this? ## To Reproduce Steps to reproduce the behavior: asset.schema.json ```json { "$id": "http://poppy.be/schemas/asset.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Physical Asset", "description": "A generic representation of a physical asset", "type": "object", "required": [ "id", "model", "location" ], "properties": { "id": { "type": "string", "format": "uuid" }, "model": { "type": "string" }, "location": { "$ref": "http://poppy.be/schemas/geo/point.json#" } } } ``` point.schema.json ```json { "$id": "http://poppy.be/schemas/geo/point.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Longitude and Latitude Values", "description": "A geographical coordinate.", "type": "object", "required": [ "latitude", "longitude" ], "properties": { "latitude": { "type": "number", "minimum": -90, "maximum": 90 }, "longitude": { "type": "number", "minimum": -180, "maximum": 180 }, "altitude": { "type": "number" } } } ``` assetResponse.schema.json ```json { "$id": "http://poppy.be/schemas/response/assetLocations.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "List of Asset locations", "type": "array", "items": { "$ref": "http://poppy.be/schemas/asset.json#" }, "default": [] } ``` Route ```js app.get('/assets', { schema: { querystring: Schemas.geo.point, response: { 200: Schemas.response.assetLocations } } }, async (req, res) => { ... }) ``` ## Expected behavior The serialization should simply be able to resolve the `asset` schema. ## Your Environment - *node version*: 10 - *fastify version*: >=1.0.0 - *os*: Mac
https://github.com/fastify/fastify/issues/1410
https://github.com/fastify/fastify/pull/1437
8d320f0cea347bb7a93b83c8b6fd1f405dec5e28
972f2e7b124d4ca692c25c1c4b1be46c6913c0e9
"2019-01-25T12:42:19Z"
javascript
"2019-02-08T21:24:38Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,406
["lib/reply.js", "package.json", "test/stream.test.js"]
Change log level to `warn` on stream error when "premature close"
## πŸš€ Feature Proposal Change log method to `res.log.warn` if client hang-up error when streaming a response (when error message is "premature close"). The change would be needed at [line 294](https://github.com/fastify/fastify/blob/7e963aa1a2a545e312de1006c510c655a38134ea/lib/reply.js#L294) and [line 306](https://github.com/fastify/fastify/blob/7e963aa1a2a545e312de1006c510c655a38134ea/lib/reply.js#L306) of reply.js If this is acceptable, I don't mind making a PR for the change! ## Motivation Strictly speaking, in a server context, it is not an error if the client hangs up, and these errors create a lot of noise, especially when stress testing a server (with `autocannon`, for example). ## Example [no example]
https://github.com/fastify/fastify/issues/1406
https://github.com/fastify/fastify/pull/1407
14d329c2c92cd184a163390d3cab2109835ad24f
42567bfc9ee4e667d4455d8f651784fc3af5f992
"2019-01-24T11:47:05Z"
javascript
"2019-01-28T15:04:22Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,405
[".npmignore"]
Shrink the npm package size by excluding test and docs
## πŸ› Bug Report Currently the fastify package on npm is including `test`, `docs`, `examples`, `tools`, `.github`. These files are not needed by a package consumer, is it okay to exclude them from npm publish? ## To Reproduce Steps to reproduce the behavior: Paste your code here: ```js npm i [email protected] ncdu node_modules ``` ## Expected behavior npm package only contains the files to support runtime and development time (like *.d.ts). Unrelated files should not be published. ## Your Environment - *node version*: 11 - *fastify version*: >=2.0.0-rc.4 - *os*: Mac
https://github.com/fastify/fastify/issues/1405
https://github.com/fastify/fastify/pull/1416
af45ca93723ed702d34759cb0afc57ffaa92267e
310cb60b439fb363b28d42eb2e0f351447c7f11b
"2019-01-24T05:57:59Z"
javascript
"2019-01-30T16:42:41Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,397
["docs/Validation-and-Serialization.md", "lib/validation.js", "test/validation-error-handling.test.js"]
Set allErrors: true in default AJV instance
## πŸš€ Feature Proposal Set `allErrors: true` in default AJV instance ## Motivation Validation should return all errors by default (I believe this is the preferred case most of the time) This will degrade performance though but not sure how much
https://github.com/fastify/fastify/issues/1397
https://github.com/fastify/fastify/pull/1398
49025313d16a5cad701fb157e090fdc99237f6b8
b5a961ef355206eef82023c6fbdb6c242dc408dd
"2019-01-17T08:02:21Z"
javascript
"2019-01-31T16:03:21Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,361
["fastify.js"]
TLS / socket hang up / ECONNRESET
After every request from client i got a server error after a minute (TLS / socket hang up / ECONNRESET), here is the pino logs: ``` [nodemon] starting `node test.js` INFO [2019-01-03 12:21:10.894 +0000] (11508 on PredatorRTW): msg: "Server listening at https://127.0.0.1:3001" GO INFO [2019-01-03 12:23:55.652 +0000] (11508 on PredatorRTW): msg: "incoming request" reqId: 1 req: { "method": "GET", "url": "/", "hostname": "localhost:3001", "remoteAddress": "127.0.0.1", "remotePort": 53161 } INFO [2019-01-03 12:23:55.658 +0000] (11508 on PredatorRTW): msg: "request completed" reqId: 1 res: { "statusCode": 200 } responseTime: 4.617481000721455 ERROR [2019-01-03 12:24:09.858 +0000] (11508 on PredatorRTW): msg: "client error" err: { "type": "Error", "message": "socket hang up", "stack": Error: socket hang up at TLSSocket.onSocketClose (_tls_wrap.js:737:23) at TLSSocket.emit (events.js:187:15) at _handle.close (net.js:616:12) at Socket.done (_tls_wrap.js:384:7) at Object.onceWrapper (events.js:273:13) at Socket.emit (events.js:182:13) at TCP._handle.close (net.js:616:12) "code": "ECONNRESET" } ``` Simple server configuration ("fastify": "^2.0.0-rc.3", node v11.2.0) ``` let fs = require('fs') const fastify = require('fastify')({ logger: { prettyPrint: { levelFirst: true, translateTime: true, messageKey: 'errStack' } }, https: { key: fs.readFileSync('./tls/cert.key'), cert: fs.readFileSync('./tls/cert.pem') } }) fastify.listen(3001, 'localhost', async (err, address) => { err ? console.log(err) : console.log('GO') }) fastify.get('/', async (request, res) => { res.send({ hello: 'world' }) }) ``` What does this error mean? Is there something wrong with my configuration?
https://github.com/fastify/fastify/issues/1361
https://github.com/fastify/fastify/pull/1363
adfa0c32b818af0f6f477dce5680bc871a5e2669
2a44139d098c7eb8e8c1b247748f5235680f70a1
"2019-01-03T11:50:25Z"
javascript
"2019-01-04T12:19:07Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,356
[".travis.yml", "README.md", "package.json"]
Add license checker somewhere
## πŸš€ Feature Proposal Why not add a license checker? ## Motivation ## Example [Like there](https://github.com/confluentinc/kafka-connect-jdbc#license)
https://github.com/fastify/fastify/issues/1356
https://github.com/fastify/fastify/pull/1357
7e963aa1a2a545e312de1006c510c655a38134ea
3f49cd1d7016539735ac52f657ea8186972f8451
"2018-12-27T12:13:42Z"
javascript
"2019-01-02T19:32:25Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,353
["lib/schemas.js", "test/input-validation.test.js"]
JSON Schema Error: missing id schema when set $schema
## πŸ› Bug Report I'm working on [issue 1329](https://github.com/fastify/fastify/issues/1329) and so I'm trying the docs I'm writing, but I got this error when using the following schema: ``` { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "someKey": { "type": "string" } } } Error: FastifyError [FST_ERR_SCH_NOT_PRESENT]: FST_ERR_SCH_NOT_PRESENT: Schema with id 'http://json-schema.org/draft-07/schema' does not exist! at Schemas.resolve (C:\Users\behem\workspace\fastify\lib\schemas.js:30:11) at Schemas.traverse (C:\Users\behem\workspace\fastify\lib\schemas.js:76:26) at Schemas.traverse (C:\Users\behem\workspace\fastify\lib\schemas.js:80:12) at Schemas.resolveRefs (C:\Users\behem\workspace\fastify\lib\schemas.js:49:10) at build (C:\Users\behem\workspace\fastify\lib\validation.js:29:28) at afterRouteAdded (C:\Users\behem\workspace\fastify\fastify.js:636:9) at C:\Users\behem\workspace\fastify\fastify.js:596:7 ``` ## To Reproduce ```js const fastify = require('fastify')({ logger: true }) const { FluentSchema } = require('fluent-schema') const bodySchema = FluentSchema() .prop( 'someKey', FluentSchema() .asString() ) const schema = { body: bodySchema.valueOf() } fastify.post('/the/url', { schema }, (request, reply) => { reply.send({ hello: 'world' }) }) fastify.listen(3000, (err, address) => { if (err) throw err fastify.log.info(`server listening on ${address}`) }) ``` ## Expected behavior I don't expect the thrown's error. The `$schema` is raccomended by the [standard](https://json-schema.org/understanding-json-schema/reference/schema.html) so, maybe I'm missing something or this field should be ignored? If I remove the `$schema` field, all is working: ```js delete schema.body.$schema ``` ## Your Environment - *node version*: 8.14.0 - *fastify version*: 2.0.0-rc.3 - *os*: Windows 10 - *fluent-schema*: 0.4.0
https://github.com/fastify/fastify/issues/1353
https://github.com/fastify/fastify/pull/1354
a584210d9a3d6d60c00232290aeeda749f58d3b1
9f9c88fed17c99675074ef095bd324515bd6c9b9
"2018-12-24T21:01:03Z"
javascript
"2018-12-26T10:00:12Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,334
["docs/Errors.md", "lib/errors.js", "lib/reply.js", "lib/wrapThenable.js", "test/hooks.test.js"]
Missing two error codes
* [ ] https://github.com/fastify/fastify/blob/1ad553df56f6833048a7e105fb500ac6db60ce2f/lib/reply.js#L65 * [ ] https://github.com/fastify/fastify/blob/1ad553df56f6833048a7e105fb500ac6db60ce2f/lib/wrapThenable.js#L19 I propose we fix those before 2.0.0 is out.
https://github.com/fastify/fastify/issues/1334
https://github.com/fastify/fastify/pull/1348
8987e618cecd69cfdc629c2f9d20e8933fab89a8
a584210d9a3d6d60c00232290aeeda749f58d3b1
"2018-12-19T08:35:03Z"
javascript
"2018-12-24T10:05:43Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,330
["docs/Errors.md", "docs/Reply.md", "lib/errors.js", "lib/reply.js", "lib/symbols.js", "lib/wrapThenable.js", "test/skip-reply-send.js"]
Do not allow the `reply.sent` property to be overwritten
Currently we allow the reply.sent property to be overwritten by a user. it should be protected by a getter, and accessed directly via a symbol inside `Reply`. This will likely conflicting with: https://github.com/fastify/fastify/pull/1328, so let's wait for that to land. I propose we land this in v2.0.0-rc.3.
https://github.com/fastify/fastify/issues/1330
https://github.com/fastify/fastify/pull/1336
249bd4a202fe5cb0d17e91df71b0b86d279a27fb
09becaf37ea482924f4bfb2e8dfed4ff58a35bdd
"2018-12-15T15:26:21Z"
javascript
"2018-12-20T09:03:29Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,329
["docs/Fluent-Schema.md", "package.json", "test/fluent-schema.js", "test/fluent-schema.test.js"]
Document the use of fluent-schema
We are receiving some questions about JSON schema in gitter and github. I think it’s time we start documenting: https://www.npmjs.com/package/fluent-schema in this repo. I think it has a more mnemonic API.
https://github.com/fastify/fastify/issues/1329
https://github.com/fastify/fastify/pull/1485
9398dfab9ed46f262e32002ab75ac7b264e57a21
29a77b9a98a12c2378cac6de306a6c9235a8511d
"2018-12-14T23:23:29Z"
javascript
"2019-03-05T09:04:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,325
["lib/reply.js", "test/validation-error-handling.test.js"]
Response validation error breaks reply lifecycle
## πŸ› Bug Report If response validation fails, `reply.send()` will thrown an Error (as expected), but the error is not handled by Fastify and it breaks the response lifecycle. This is the code of `reply.send`. I commented the 2 important lines. ```js Reply.prototype.send = function(payload) { if (this.sent) { this.res.log.warn({ err: new Error('Reply already sent') }, 'Reply already sent'); return; } // ⚠️ If in this method is thrown an error, this flag remains true ⚠️ this.sent = true; if (payload instanceof Error || this._isError === true) { handleError(this, payload, onSendHook); return; } if (payload === undefined) { onSendHook(this, payload); return; } var contentType = getHeader(this, 'content-type'); var hasContentType = contentType !== undefined; if (payload !== null) { if (Buffer.isBuffer(payload) || typeof payload.pipe === 'function') { if (hasContentType === false) { this._headers['content-type'] = CONTENT_TYPE.OCTET; } onSendHook(this, payload); return; } if (hasContentType === false && typeof payload === 'string') { this._headers['content-type'] = CONTENT_TYPE.PLAIN; onSendHook(this, payload); return; } } if (this._serializer) { payload = this._serializer(payload); } else if (hasContentType === false || contentType.indexOf('application/json') > -1) { if (hasContentType === false || contentType.indexOf('charset') === -1) { this._headers['content-type'] = CONTENT_TYPE.JSON; } // ⚠️ Throw error on validation error ⚠️ payload = serialize(this.context, payload, this.res.statusCode); flatstr(payload); } onSendHook(this, payload); }; ``` When `serialize(this.context, payload, this.res.statusCode);` throws an error, `onSendHook` is never called, but `this.sent` remains `true`. This is not *really* true, because to the client is not sent any response. In my route I can catch the error and would treat it as server error: ```js try { reply.send(invalidResponse) } catch (error) { // We tried to return an invalid response. Handle it as a server error reply.code(500).send('Internal Server Error'); // throw reply already sent } ``` But it throws reply already sent, due to the `sent` flag set to true. In this case, to the client isn't sent anything and the connection still opened until timeout. ## To Reproduce Steps to reproduce the behavior: Just create a route and return an invalid response. ```js const options = { schema: { response: { 200: { type: 'object', required: ['_id', 'value'], properties: { _id: { type: 'string', }, value: { type: 'string', }, }, }, }, }, }; fastify.get('/', options, (request, reply) => { try { // Throw an error due to prop name typo reply.send({ _id: 'someid', valu: 'wrong_prop_name' }); } catch (error) { // throw reply already sent reply.code(500).send('Internal Server Error'); } }); ``` The app hangs up with "reply already sent" and nothing is sent to the client ## Expected behavior I expect that: - Fastify returns a server error automatically, on validation error. OR - Sent isn't set to true until the response I really sent ## My Environment - *node version*: 10 - *fastify version*: 1.13.1 - *os*: Mac, Linux. Windows not tested
https://github.com/fastify/fastify/issues/1325
https://github.com/fastify/fastify/pull/1328
1ad553df56f6833048a7e105fb500ac6db60ce2f
249bd4a202fe5cb0d17e91df71b0b86d279a27fb
"2018-12-14T12:32:37Z"
javascript
"2018-12-19T18:21:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,321
["fastify.d.ts", "package.json", "test/types/index.ts"]
`@types/pino` should not be in `dependencies`
Before you submit an issue we recommend you drop into the [Gitter community](https://gitter.im/fastify) or [Fastify Help](https://github.com/fastify/help) and ask any questions you have or mention any problems you've had getting started with Fastify. **Please read this entire template before posting any issue. If you ignore these instructions and post an issue here that does not follow the instructions, your issue might be closed, locked, and assigned the `missing discussion` label.** ## πŸ› Bug Report A clear and concise description of what the bug is. ## To Reproduce Steps to reproduce the behavior: Paste your code here: ```js ``` ## Expected behavior A clear and concise description of what you expected to happen. Paste the results here: ```js ``` ## Your Environment - *node version*: 6,8,10 - *fastify version*: >=1.0.0 - *os*: Mac, Windows, Linux - *any other relevant information*
https://github.com/fastify/fastify/issues/1321
https://github.com/fastify/fastify/pull/1366
5ab122d702f633d9bc5bc5b70036d6973b0129f3
e2062efcc7adbb82101e3afd7734835f81d71bbe
"2018-12-13T10:03:11Z"
javascript
"2019-01-10T11:30:36Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,316
["docs/Logging.md"]
Response payload in default pino logger
## Hi! How can I log response payload using default pino logger? ##### For now I have next config: ``` const fastify = require('fastify')({ logger: { prettyPrint: true, serializers: { req(req) { return { method: req.method, url: req.url, path: req.path, parameters: req.parameters, body: req.body, headers: req.headers, }; }, }, }, }); ``` Thanks!
https://github.com/fastify/fastify/issues/1316
https://github.com/fastify/fastify/pull/1455
1ee924f0d568f7c02918ebcace22c02c9ea45750
d785957545315f5ae77912dc46f04000f4135c7f
"2018-12-11T11:01:23Z"
javascript
"2019-03-10T09:39:03Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,278
["CONTRIBUTING.md", "README.md"]
Add clarification on where the code for supported lines lives
We need to amend our README.md or CONTRIBUTING.md to explain that the code for v1 lives in https://github.com/fastify/fastify/tree/1.x.
https://github.com/fastify/fastify/issues/1278
https://github.com/fastify/fastify/pull/1301
3ca19b77eb67a85371259ee41e6c0a89767351b3
356889928948ae7954210f5490cd838b86497033
"2018-11-27T09:34:07Z"
javascript
"2018-12-20T09:17:17Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,276
["docs/Middlewares.md"]
Questions about mounting Express App
## πŸ‘‰ [Please follow one of these issue templates](https://github.com/fastify/fastify/issues/new/choose) πŸ‘ˆ #### You have already researched for similar issues? yes i have similar problems are present but Im looking for more of an example since I cant get things working right. #### Are you sure this is an issue with the fastify or are you just looking for some help? https://github.com/fastify/fastify/issues/306 Talks about a similar issues so does https://github.com/fastify/fastify/issues/1175 What im trying to do is use https://github.com/bee-queue/arena#readme inside a fasitfy app. When i use fastify.use (arena) I get a working sub app but my other routes do no work. Similary if I disable the arena sub app all my other routes work. Can anyone please advise or demonstrate mounting an express sub app. I seem to always get in a position where the sub app works and the rest of the application hangs on requests. If i disable the sub app everything works as expected but I have disabled the sub app. Thanks
https://github.com/fastify/fastify/issues/1276
https://github.com/fastify/fastify/pull/1313
1f5fd580c6166d8b1063befd5aea0def75df2174
7b38fc693dcb361447d9293790c55c745a8175f8
"2018-11-26T16:27:24Z"
javascript
"2018-12-14T09:08:00Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,269
["docs/ContentTypeParser.md", "lib/contentTypeParser.js", "test/custom-parser.test.js", "test/helper.js"]
Question: Has a text/plain content parser plugin been published?
## πŸ’¬ Questions and Help If not, what's best practice? Should we roll our own or try to use express body-parser? Thanks
https://github.com/fastify/fastify/issues/1269
https://github.com/fastify/fastify/pull/1280
592a619e20179c218b50db77eb67729951f839d8
aee0840b2d4b762b809c92fba8350618b3aed7d3
"2018-11-25T22:24:23Z"
javascript
"2018-12-13T18:18:29Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,249
["fastify.d.ts", "test/types/index.ts"]
[types] Fastify error fields
Now in `fastify.d.ts` routes, middleware and so on use `Error` type. However, as far as I know, Fastify could have couple additional properties like `statusCode` or `validation`. So it's better to introduce custom interface or class that extends `Error` and use it. Also it will be easier to extend that interface in plugins if they add some new fields to the Error type. I could try make PR, but I don't know if there are any other properties. So that would be great if someone will help with listing all available error properties. - *fastify version*: latest
https://github.com/fastify/fastify/issues/1249
https://github.com/fastify/fastify/pull/1250
671ad17b66bea5f480de21773194b279339c321e
fc985a5cf59f47029d161c2e74d29698b054023e
"2018-11-08T21:34:49Z"
javascript
"2018-12-10T11:09:34Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,246
["README.md"]
Add benchmark NodeJS 10.13.0
Can you add NodeJS 10.13.0 requests/sec benchmark to the README ?
https://github.com/fastify/fastify/issues/1246
https://github.com/fastify/fastify/pull/1294
d0bdb4ddf770099a9ddf28c9f820615203b3e2ae
7ddc19f354853dcafbd776cc3a350d1ce00f181f
"2018-11-07T06:52:05Z"
javascript
"2018-12-03T08:47:52Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,241
["package.json"]
An in-range update of typescript-eslint-parser is breaking the build 🚨
## The devDependency [typescript-eslint-parser](https://github.com/eslint/typescript-eslint-parser) was updated from `20.0.0` to `20.1.0`. 🚨 [View failing branch](https://github.com/fastify/fastify/compare/master...fastify:greenkeeper%2Ftypescript-eslint-parser-20.1.0). This version is **covered** by your **current version range** and after updating it in your project **the build failed**. typescript-eslint-parser is a devDependency of this project. It **might not break your production code or affect downstream projects**, but probably breaks your build or test tools, which may **prevent deploying or publishing**. <details> <summary>Status Details</summary> - ❌ **continuous-integration/appveyor/branch:** Waiting for AppVeyor build to complete ([Details](https://ci.appveyor.com/project/mcollina/fastify/builds/19931533)). - ❌ **continuous-integration/travis-ci/push:** The Travis CI build failed ([Details](https://travis-ci.org/fastify/fastify/builds/448637761?utm_source=github_status&utm_medium=notification)). </details> --- <details> <summary>Release Notes for v20.1.0</summary> <ul> <li><a class="commit-link" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/075d24300ee715534f36d0779cf0222a6ac78831"><tt>075d243</tt></a> Chore: Make ESLint a devDependency/peerDependency (fixes <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="365962564" data-permission-text="Issue title is private" data-url="https://github.com/eslint/typescript-eslint-parser/issues/523" data-hovercard-type="issue" data-hovercard-url="/eslint/typescript-eslint-parser/issues/523/hovercard" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/issues/523">#523</a>) (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="369752667" data-permission-text="Issue title is private" data-url="https://github.com/eslint/typescript-eslint-parser/issues/526" data-hovercard-type="pull_request" data-hovercard-url="/eslint/typescript-eslint-parser/pull/526/hovercard" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/pull/526">#526</a>) (Kevin Partington)</li> <li><a class="commit-link" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/4310aaca670e9e5b36c901657bd403253ba48f2f"><tt>4310aac</tt></a> Chore: Force LF for tsx files (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="364693064" data-permission-text="Issue title is private" data-url="https://github.com/eslint/typescript-eslint-parser/issues/520" data-hovercard-type="pull_request" data-hovercard-url="/eslint/typescript-eslint-parser/pull/520/hovercard" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/pull/520">#520</a>) (Benjamin Lichtman)</li> <li><a class="commit-link" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/bacac5f0a29b08ee1d43df55ff3a7e9ae6a8226a"><tt>bacac5f</tt></a> New: Add visitor keys (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="362961921" data-permission-text="Issue title is private" data-url="https://github.com/eslint/typescript-eslint-parser/issues/516" data-hovercard-type="pull_request" data-hovercard-url="/eslint/typescript-eslint-parser/pull/516/hovercard" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/pull/516">#516</a>) (MichaΕ‚ SajnΓ³g)</li> <li><a class="commit-link" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/4172933d6cb67cc12071e37dafbd75bc56b31a6c"><tt>4172933</tt></a> Upgrade: [email protected] (<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="371296213" data-permission-text="Issue title is private" data-url="https://github.com/eslint/typescript-eslint-parser/issues/527" data-hovercard-type="pull_request" data-hovercard-url="/eslint/typescript-eslint-parser/pull/527/hovercard" href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/pull/527">#527</a>) (Teddy Katz)</li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 6 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/de1f5149614a8aa18dc85fe603d96f1310f8b89c"><code>de1f514</code></a> <code>20.1.0</code></li> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/edbe70e70d307020172ce715888259f9052ca4fa"><code>edbe70e</code></a> <code>Build: changelog update for 20.1.0</code></li> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/075d24300ee715534f36d0779cf0222a6ac78831"><code>075d243</code></a> <code>Chore: Make ESLint a devDependency/peerDependency (fixes #523) (#526)</code></li> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/4310aaca670e9e5b36c901657bd403253ba48f2f"><code>4310aac</code></a> <code>Chore: Force LF for tsx files (#520)</code></li> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/bacac5f0a29b08ee1d43df55ff3a7e9ae6a8226a"><code>bacac5f</code></a> <code>New: Add visitor keys (#516)</code></li> <li><a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/commit/4172933d6cb67cc12071e37dafbd75bc56b31a6c"><code>4172933</code></a> <code>Upgrade: [email protected] (#527)</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/eslint/typescript-eslint-parser/compare/ee396b9c7052b95aa12c8f59dd17816d8d5ba0ac...de1f5149614a8aa18dc85fe603d96f1310f8b89c">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) Bot :palm_tree:
https://github.com/fastify/fastify/issues/1241
https://github.com/fastify/fastify/pull/1242
2c007d530ef462279a2253aed496e11563e6b75c
7e18ab4c131229bdfacbc52e91d25cf43e963486
"2018-10-31T01:09:44Z"
javascript
"2018-10-31T16:31:28Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,218
["README.md", "appveyor.yml", "azure-pipelines-npm-template.yml", "azure-pipelines-yarn-template.yml", "azure-pipelines.yml", "docs/Getting-Started.md", "docs/LTS.md", "package.json"]
Switch to Azure pipelines for CI
## πŸš€ Feature Proposal We should switch to [Azure pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) for CI ## Motivation * Free for opensource with 10 Parallel Jobs and unlimited build time * Support for Mac, Windows and Linux * Easy installation as with Travis * Much better configuration and debugging experience * Full Github integration * Cross platform builds are much faster than in travis right now. ## Example ![image](https://user-images.githubusercontent.com/1764424/47241255-53b5d180-d3eb-11e8-9d7e-f9d6d800f144.png) Example configuration: https://github.com/Prettyhtml/prettyhtml/blob/master/azure-pipelines.yml
https://github.com/fastify/fastify/issues/1218
https://github.com/fastify/fastify/pull/1226
584bc2867749c07e089af7bee216627919b26b65
c53174cb8ca388d88a6834c62808922ea0f47c28
"2018-10-19T20:09:11Z"
javascript
"2018-11-18T12:26:17Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,202
["docs/Routes.md", "docs/Validation-and-Serialization.md", "fastify.d.ts", "fastify.js", "lib/handleRequest.js", "test/internals/handleRequest.test.js", "test/validation-error-handling.test.js"]
Custom request validation error responses
Currently, `ajv` is bailing immediately when there is an error in the request schema sending back the default error message. As also stated in one of the `gitter` conversations, we need a way to override this behavior for custom error messages/responses.
https://github.com/fastify/fastify/issues/1202
https://github.com/fastify/fastify/pull/1238
347957c77e384d44b90adc9ad9347a0974ada922
ddc4e460cc6ec514c1b92b64214acc713137c7e2
"2018-10-08T07:28:53Z"
javascript
"2018-10-30T16:29:39Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,182
["docs/Server.md", "fastify.js", "test/route-prefix.test.js"]
rename fastify.basePath to fastify.prefix
`fastify.basePath` is really _unintuitive_, and we use `prefix`Β  as the option for plugins. I think the terms should match. I propose we deprecate `basePath` and add `prefix`Β  in v2. If somebody wants to pick it up, target the next branch.
https://github.com/fastify/fastify/issues/1182
https://github.com/fastify/fastify/pull/1183
a93588f472bfa668a75445df479d55e93f81ccb9
42ac663bb1751c5b934df7b25533f143295dffb9
"2018-09-22T08:12:31Z"
javascript
"2018-09-28T09:51:23Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,158
["lib/validation.js"]
Fastify Joi header validation failed
``` fastify.get('/profile', { schema: { headers: { Authorization: Joi.object({ 'Authorization': Joi.string().required() }).options({ allowUnknown: true }) } }, schemaCompiler: schema => data => Joi.validate(data, schema) }, Controller.profile) ``` generates the following error ``` { "statusCode": 400, "error": "Bad Request", "message": "\"content-type\" is not allowed. \"authorization\" is not allowed. \"cache-control\" is not allowed. \"postman-token\" is not allowed. \"user-agent\" is not allowed. \"accept\" is not allowed. \"host\" is not allowed. \"accept-encoding\" is not allowed. \"content-length\" is not allowed. \"connection\" is not allowed" } ``` if I use header validation in the following manner; ``` fastify.get('/profile', { schema: { headers: Joi.object({ 'Authorization': Joi.string().required() }).options({ allowUnknown: true }) }, schemaCompiler: schema => data => Joi.validate(data, schema) }, Controller.profile) ``` generates this output. ``` return schema._validateWithOptions(value, options, callback); ^ TypeError: schema._validateWithOptions is not a function ``` Need some help of figuring out what's happening
https://github.com/fastify/fastify/issues/1158
https://github.com/fastify/fastify/pull/1178
c21932c51f69811271f78292d4e4fea76c2a5a67
0afa85806988d468afeb0243589470e353667397
"2018-09-14T20:03:03Z"
javascript
"2018-09-21T12:48:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,129
["README.md", "docs/Error-Handling.md"]
Hook exceptions crash Fastify
Not sure if this is a desired behavior (user should handle exceptions instead) but having something like ```js fastify.addHook('preHandler', (request, reply, next) => { throw new Error('test') }) fastify.addHook('onResponse', (req, res, next) => { throw new Error('test') }) ``` on any hook will crash Fastify. Should it just handle the exceptions and return `500` (or at least log them and not crash) ? I think this can be patched via something like below but maybe there is a better solution ```js function hookIterator(fn, reply, next) { if (reply.res.finished === true) return undefined try { return fn(reply.request, reply, next) } catch (err) { reply.sent = false reply._isError = true reply.send(err) } } ``` ```js function onResponseIterator(fn, res, next) { try { return fn(res, next) } catch (err) { res.log.error({ res, err }, 'request errored') } } ```
https://github.com/fastify/fastify/issues/1129
https://github.com/fastify/fastify/pull/1130
15fbe248eb8e90e99992a520f5abf4f0dbe419dd
4b5f818b08d0eea02c46c782281fe90ff596830a
"2018-09-01T18:03:17Z"
javascript
"2018-09-17T12:41:33Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,117
["lib/reply.js", "test/logger.test.js"]
No more logs when using setErrorHandler after 1.10.0 patch
Hi to all. I have a problem with this specific [1073 fix](https://github.com/fastify/fastify/pull/1073): it completely breaks errors logging. Here's a dummy repository that show the problem: https://github.com/fox1t/fastify-errors-handler-test ``` {"level":30,"time":1535552922845,"msg":"incoming request","pid":47492,"hostname":"Maksims-MacBook-Pro.local","reqId":1,"req":{"id":1,"method":"GET","url":"/api/v1/error","remoteAddress":"127.0.0.1","remotePort":50699},"v":1} {"level":30,"time":1535552922856,"msg":"request completed","pid":47492,"hostname":"Maksims-MacBook-Pro.local","reqId":1,"res":{"statusCode":500},"responseTime":10.98310899734497,"v":1} ``` On fastify 1.8.0 it worked and still works as expected. ``` {"level":30,"time":1535552052901,"msg":"incoming request","pid":45814,"hostname":"Maksims-MacBook-Pro.local","reqId":1,"req":{"id":1,"method":"GET","url":"/api/v1/error","remoteAddress":"127.0.0.1","remotePort":65469},"v":1} {"level":50,"time":1535552052905,"msg":"/error route","pid":45814,"hostname":"Maksims-MacBook-Pro.local","reqId":1,"req":{"id":1,"method":"GET","url":"/api/v1/error","remoteAddress":"127.0.0.1","remotePort":65469},"res":{"statusCode":500},"err":{"type":"Error","message":"/error route","stack":"Error: /error route\n at Object.fastify.get (/Users/maksim/Projects/fox1t/error-test/routes.js:3:11)\n at preHandlerCallback (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/lib/handleRequest.js:91:30)\n at handler (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/lib/handleRequest.js:75:5)\n at handleRequest (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/lib/handleRequest.js:18:5)\n at onRunMiddlewares (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/fastify.js:440:5)\n at middlewareCallback (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/fastify.js:428:7)\n at Object.routeHandler [as handler] (/Users/maksim/Projects/fox1t/error-test/node_modules/fastify/fastify.js:286:7)\n at Router.lookup (/Users/maksim/Projects/fox1t/error-test/node_modules/find-my-way/index.js:319:17)\n at Server.emit (events.js:182:13)\n at parserOnIncoming (_http_server.js:652:12)"},"v":1} {"level":30,"time":1535552052910,"msg":"request completed","pid":45814,"hostname":"Maksims-MacBook-Pro.local","reqId":1,"res":{"statusCode":500},"responseTime":9.093263000249863,"v":1} ``` The only solution for me seems to add explicit call to `req.log.error(err)` inside my custom handler. Is this the way that is expected to work? * *node version*: > 10 * *fastify version*: >=1.11.0 * *os*: Mac Thanks in advance.
https://github.com/fastify/fastify/issues/1117
https://github.com/fastify/fastify/pull/1119
288d9ec3da383630348c46f9cf94f2db13e7dd70
45fb2f45f2de41276fe0b2cac03d89e9580d2085
"2018-08-29T14:38:41Z"
javascript
"2018-08-29T15:50:36Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,115
["package.json"]
`npm run lint` does not work with pnpm installed dependencies
```sh $ git clone https://github.com/fastify/fastify.git $ cd fastify $ pnpm install $ npm run lint # will fail ``` This results in git commits failing: ![image](https://user-images.githubusercontent.com/321201/44791782-6b51a600-ab70-11e8-917e-1405da7f4628.png) However, running `standard | snazzy` will work just fine. The issue is with the TypeScript linting.
https://github.com/fastify/fastify/issues/1115
https://github.com/fastify/fastify/pull/1118
cef8814ea104101f84bc385408b661b073e17cd2
288d9ec3da383630348c46f9cf94f2db13e7dd70
"2018-08-29T13:47:32Z"
javascript
"2018-08-29T14:56:41Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,107
["docs/Ecosystem.md"]
Plugin: fastify-schedule
Some of the frameworks I came across has a schedule plugin like [here](https://github.com/miaowing/nest-schedule) and [here](https://github.com/eggjs/egg-schedule). They usually benefit from [node-schedule](https://www.npmjs.com/package/node-schedule) or wrap their own scheduler around [cron-parser](https://github.com/harrisiirak/cron-parser). I am thinking of attempting a plugin like this. I will probably use `node-schedule` as the underlying scheduler. Any thoughts?
https://github.com/fastify/fastify/issues/1107
https://github.com/fastify/fastify/pull/2806
f1238f65ab0bbb579bf4173af302bc81b19631db
5ca670931b60e988a57ef559e24b08ed60ddb074
"2018-08-27T20:33:43Z"
javascript
"2021-01-20T13:49:36Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,099
["fastify.js"]
Suspected dead code in listenPromise
#### You have already researched for similiar issues? Yes #### Are you sure this is an issue with the fastify or are you just looking for some help? This seems to be a dead code in fastify #### Is this a security related issue? No #### What are you trying to achieve or the steps to reproduce? I was trying to add a test for covering the following line https://github.com/fastify/fastify/blob/6bce249e04c60914280b5919efdb4ded6a745925/fastify.js#L314 I noticed that the address can never be undefined as it's set to `'127.0.0.1'` is calling function https://github.com/fastify/fastify/blob/6bce249e04c60914280b5919efdb4ded6a745925/fastify.js#L347-L359 #### What did you expect? Is the check on the following line redundant? https://github.com/fastify/fastify/blob/6bce249e04c60914280b5919efdb4ded6a745925/fastify.js#L314
https://github.com/fastify/fastify/issues/1099
https://github.com/fastify/fastify/pull/1102
e6bca66cf938386cb8a640b9130129ad8b941ac0
acf39508fc6653112dc8198269222789339d4e51
"2018-08-26T07:24:18Z"
javascript
"2018-08-26T22:52:46Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,090
["docs/Server.md", "fastify.js", "package.json", "test/plugin.test.js"]
Make plugintTimeout default be X seconds in v2
as titled
https://github.com/fastify/fastify/issues/1090
https://github.com/fastify/fastify/pull/1145
484980a6ba836a5119f86b783bc4cfce0be02bf9
77bed1d369381b93184cef7c1c51ee0b6aa71453
"2018-08-24T18:43:53Z"
javascript
"2018-09-09T10:53:45Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,072
["lib/reply.js", "test/logger.test.js"]
Thrown errors processed by the errorHandler are logged as 500 even if status code is altered
Whether a `reply.send(new CustomHTTPError())` or `throw new CustomHTTPError()` is used, the default logger always logs it at error level even if the error does not correspond to an internal error (e.g. NotFound or Unauthorized). In my specific async/await situation I'm throwing Boom errors and I'm processing them through the errorHandler to return the correct HTTP error to the client (like "fastify-boom" does, but I removed the dependency to investigate this behaviour). The client receives the correct HTTP code and Fastify logs it at _error_ level. This makes sense when a 5xx error is thrown but I would expect 4xx errors to be logged at _info_ level. Changing the error code through the error handler `reply.res.statusCode = <code>` does nothing (the error seems to be logged before the handler is called). The only way to get the right result is to throw a custom Error instance [docs](https://github.com/fastify/fastify/blob/master/docs/Reply.md#errors) but this adds the complexity that Boom removes. ```js const error = new Error(); error.statusCode = 401; throw error; ``` (which results in duplicated logs but that's another issue) I would expect handled errors to be logged with respect to the final status code or to not be logged at all (like a try/catch block) and the request log to report the correct status code. My final objective is to keep track of the status code of the request when the server output is piped to `pino` or `pino-colada` without having to check the source json. Here's some code to reproduce the behaviour (I pipe the output to `pino` or `pino-colada`) ```js const fastify = require("fastify"); const boom = require("boom"); const server = fastify({ logger: true, }); server.setErrorHandler((error, req, reply) => { if (error && error.isBoom) { reply.code(error.output.statusCode).type("application/json").headers(error.output.headers).send(error.output.payload); return; } reply.send(error); }); server.get('/internal', async (request, reply) => { throw boom.internal(); }); server.get('/unauthorized', async (request, reply) => { throw boom.unauthorized(); }); server.get('/notfound', async (request, reply) => { throw boom.notFound(); }); server.get('/notfound-custom', async (request, reply) => { const error = new Error(); error.statusCode = 404; error.message = "not found"; throw error; }); server.get('/unauthorized-custom', async (request, reply) => { const error = new Error(); error.statusCode = 401; error.message = "unauthorized"; throw error; }); server .listen(8000, "0.0.0.0") .then(() => {}) .catch(err => console.log(err)); ``` This is the log (piped to `pino-colada`) ``` 18:55:41 ✨ incoming request GET xxx /internal 18:55:41 🚨 Internal Server Error GET 500 /internal 18:55:41 ✨ request completed 6ms 18:55:41 ✨ incoming request GET xxx /unauthorized 18:55:41 🚨 Unauthorized GET 500 /unauthorized 18:55:41 ✨ request completed 1ms 18:55:41 ✨ incoming request GET xxx /notfound 18:55:41 🚨 Not Found GET 500 /notfound 18:55:41 ✨ request completed 1ms 18:55:41 ✨ incoming request GET xxx /notfound-custom 18:55:41 ✨ Not Found 18:55:41 ✨ Not Found 18:55:41 ✨ request completed 1ms 18:55:41 ✨ incoming request GET xxx /unauthorized-custom 18:55:41 ✨ unauthorized 18:55:41 ✨ unauthorized 18:55:41 ✨ request completed 0ms ```
https://github.com/fastify/fastify/issues/1072
https://github.com/fastify/fastify/pull/1073
4ca6f608bf3c41e5baf0dd51f574f45d249973ac
01b09784f7bd051736e708ccf9442c6ac3ee073d
"2018-08-08T16:54:13Z"
javascript
"2018-08-17T10:24:04Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,057
[".github/workflows/benchmark-parser.yml", ".github/workflows/benchmark.yml", ".github/workflows/ci.yml", ".github/workflows/coverage-nix.yml", ".github/workflows/coverage-win.yml", ".github/workflows/integration.yml", ".github/workflows/links-check.yml", ".github/workflows/lint-ecosystem-order.yml", ".github/workflows/md-lint.yml", ".github/workflows/package-manager-ci.yml"]
Rename `Server method` documentation
The `Server method` documentation doesn't describe only "methods" https://github.com/fastify/fastify/blob/92f474ea8c981bca64f46427383ed56d50d40998/docs/Server-Methods.md#basepath https://github.com/fastify/fastify/blob/92f474ea8c981bca64f46427383ed56d50d40998/docs/Server-Methods.md#log Which name could fit better?
https://github.com/fastify/fastify/issues/1057
https://github.com/fastify/fastify/pull/5048
edd220373743b2b8f42945e479d254d7f98c07ec
cc6c04ec8ef05799733f6dfa9055a0d357eac4f4
"2018-07-27T10:13:41Z"
javascript
"2023-09-19T06:32:19Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,029
["lib/logger.js", "test/logger.test.js"]
Duplicate req id in incoming request log
The default logger output request id twice in the "incoming request" log record. As the request id may be not so short, this is a waste of log size. A sample log is below, where the req id is generated by `nanoid` module. ``` {"level":30,"msg":"incoming request","reqId":"zvTdkL3H_Pm3NeSgG0ByD","req":{"id":"zvTdkL3H_Pm3NeSgG0ByD","method":"GET","url":"/ping","remoteAddress":"127.0.0.1","remotePort":61820},"v":1} ``` I think the `req.id` field could be removed to retain the `reqId` field to keep accorded with "request completed" log. #### Context * *node version*: 10 * *fastify version*: ^1.7.0 * *os*: Mac
https://github.com/fastify/fastify/issues/1029
https://github.com/fastify/fastify/pull/1032
779695f996585e19e8b44bd94fd384612c553a1b
feec6ccbe7f4b3c669317c7a8c098866ff203d82
"2018-07-09T04:47:26Z"
javascript
"2018-07-12T17:47:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,022
["README.md", "docs/Server-Methods.md", "fastify.js"]
Strange behavior at first call and after 5s
#### Context * *node version*: 10.0.0 * *fastify version*: ^1.6.0 Hi, I'am using fastify through a small nestjs project. I have a single GET REST method. Using Fastify, the first call takes 500ms at minimum and if I continue calling the same method, the response time falls arround 4ms. BUT, if I wait 5 seconds between 2 calls, the second call replies after 500ms again. I do not see this problem using Express. Anyone else experienced this behavior? Thank you
https://github.com/fastify/fastify/issues/1022
https://github.com/fastify/fastify/pull/1047
7b5b4dff290d662b133428b8e6f0156f326661cd
ed1213ecd0545730c3a214e931c5210d916445b3
"2018-07-05T06:37:42Z"
javascript
"2018-07-20T10:54:40Z"
closed
fastify/fastify
https://github.com/fastify/fastify
1,007
["docs/Factory.md", "fastify.js", "package.json", "test/case-insensitive.test.js"]
Case insensitive routes?
For a project I'm working on using Fastify, there are a collection of routing keywords. - content - shop - product ... Due to URLs that are out in the wild these could be also be requested in sentence case. With this simple example: ```JavaScript const fastify = require('fastify')() // Declare a route fastify.get('/hello', function (request, reply) { reply.send({ hello: 'world' }) }) fastify.listen(3000, (err, address) => { if (err) throw err fastify.log.info(`server listening on ${address}`) }) ``` I noticed the routes are case sensitive. ```Bash $ curl -I http://localhost:3000/hello # HTTP/1.1 200 OK $ curl -I http://localhost:3000/Hello # HTTP/1.1 404 Not Found ``` I was unaware of this before, I looked at [find-my-way](https://github.com/delvedor/find-my-way) but couldn't see any options, I assume this is for performance reasons? I understand I could make the routes regular expressions but I know this is expensive. I just wanted to double check if I was missing something simple, this is a must have for me and I would rather not build a regex if possible. Thanks, Robin
https://github.com/fastify/fastify/issues/1007
https://github.com/fastify/fastify/pull/1017
0dfb356c1d12ba86de3fbdefb8e5046d1907501e
92ee7dba30f62a0ee211f2e50e948328fce4077c
"2018-06-29T16:45:35Z"
javascript
"2018-07-03T11:40:25Z"
closed
fastify/fastify
https://github.com/fastify/fastify
961
["docs/Server.md", "fastify.d.ts", "fastify.js", "lib/context.js", "lib/reply.js", "lib/route.js", "lib/symbols.js", "test/internals/reply.test.js", "test/types/index.ts"]
Output validation
Currently, route configurations sort of overload the `schema` configuration. It doubles as input *validation* and for output *serialization*. This is confusing to users expecting it to be solely for *validation* of all potential targets. Thus, when combined with the ability to supply alternate validators, e.g. Joi, we encounter a situation where the user will write an output validation that causes errors. As an example: ```js server.route({ path: '/foo', method: 'GET', schema: { response: { 200: joi.object({ foo: joi.string().required() }) } }, handler (req, res) { res.send({foo: 'bar'}) } }) ``` A user expecting schemas to be for validation may write this sort of schema and it will result in a circular reference error since Fastify is attempting to serialize according to the circular Joi schema. The short solution is to replace the serializer for this route. However, that is not feasible when every route in a project should have the serializer replaced. Thus, we need to be able to supply a global serializer.
https://github.com/fastify/fastify/issues/961
https://github.com/fastify/fastify/pull/1706
901911c553bea62a21799ec7df34d5e36d2bacd0
78c867f46ad17265f019dd8e84148a21bc4c33b6
"2018-06-05T15:59:08Z"
javascript
"2019-06-24T16:10:54Z"
closed
fastify/fastify
https://github.com/fastify/fastify
931
["fastify.d.ts"]
JSONSchema in typescript definition is not a JSONSchema
``` interface JSONSchema { // TODO - define/import JSONSchema types body?: Object querystring?: Object params?: Object response?: { [code: number]: Object, [code: string]: Object } } ``` Is not a JSONSchema. The fields are
https://github.com/fastify/fastify/issues/931
https://github.com/fastify/fastify/pull/939
71dfd8be932e598c801ae664eacfc45739e9098f
3628524a0bd05e7464cee1b7d5f8eab26478cbd2
"2018-05-09T09:10:34Z"
javascript
"2018-05-15T21:02:36Z"
closed
fastify/fastify
https://github.com/fastify/fastify
913
["docs/ContentTypeParser.md", "docs/Reply.md", "docs/Testing.md", "lib/reply.js", "test/helper.js", "test/hooks.test.js", "test/internals/reply.test.js"]
Use UTF8 as default charset for Text and JSON
Hi, when I return a string like `Γ„ΓœΓ–` the browser is interpreted as ``` Γƒβ€žΓƒΕ“Γƒβ€“ ``` fastify will respond with ``` content-type: text/html; content-type: application/json; ``` it's obvious that I use the wrong charset but UTF8 is defacto standard and should be used as default. ``` content-type: text/html; charset=utf-8 content-type: application/json; charset=utf-8 ``` > A Unicode encoding such as UTF-8 is a good choice for a number of [reasons](https://www.w3.org/International/questions/qa-choosing-encodings). References: * https://www.w3.org/International/questions/qa-choosing-encodings * https://www.w3.org/International/articles/http-charset/index#charset
https://github.com/fastify/fastify/issues/913
https://github.com/fastify/fastify/pull/914
2907be7c5352926eda073c5a4be7701f7de39006
92a17255c45f9e264016eec7020d96adfbcd5007
"2018-04-29T14:20:59Z"
javascript
"2018-04-30T11:32:47Z"
closed
fastify/fastify
https://github.com/fastify/fastify
894
["lib/ContentTypeParser.js", "test/custom-parser.test.js"]
delete method must have body
I remember that http delete method supports sending header information to complete a request without sending the body of the request body. However, when sending a delete request with fastify, it is found that it must take the body. Otherwise, there will be json error. The error is as follows: ```js { "statusCode": 400, "error": "Bad Request", "message": "Unexpected end of body input" } ``` I would like to ask if this is a bug or design?
https://github.com/fastify/fastify/issues/894
https://github.com/fastify/fastify/pull/895
bec2da146714b6243ff1a0b24a0469e6bbcd116d
8c5e732f2e9b5f4c435589f8c5f0f5950bba9cea
"2018-04-20T12:55:15Z"
javascript
"2018-04-21T22:08:59Z"
closed
fastify/fastify
https://github.com/fastify/fastify
880
["fastify.d.ts", "test/types/index.ts"]
typescript compile error
#### What are you trying to achieve or the steps to reproduce? when use typescript , cannot pass argument to fastify() server.ts: ```ts import * as fastify from 'fastify' import { Server, IncomingMessage, ServerResponse } from 'http' const server: fastify.FastifyInstance<Server, IncomingMessage, ServerResponse> = fastify({ logger: process.env.NODE_ENV === 'dev' ? true : false }) ``` #### What was the result you received? TSError: β¨― Unable to compile TypeScript server.ts: Argument of type '{ logger: boolean; }' is not assignable to parameter of type 'ServerOptionsAsSecureHttp2' #### What did you expect? typescript compile ok #### Context * *node version*: 8.9 * *fastify version*: >=1.2.1 * *os*: Mac * *any other relevant information*: * *typescript*: 2.4.2 **Please read this entire template before posting any issue. If you ignore these instructions and post an issue here that does not follow the instructions, your issue might be closed, locked, and assigned the `missing discussion` label.**
https://github.com/fastify/fastify/issues/880
https://github.com/fastify/fastify/pull/881
470882411f9b2b1a6fd06911ea5a6e2ee7a50ba2
fdb65baa59a1032ea5330e5aef9c5dee9480a527
"2018-04-11T03:57:06Z"
javascript
"2018-04-11T14:58:13Z"
closed
fastify/fastify
https://github.com/fastify/fastify
875
["README.md", "docs/Getting-Started.md", "docs/Server-Methods.md", "examples/simple.js", "fastify.d.ts", "fastify.js", "test/listen.test.js"]
Return URL from listen method?
:wave: hi there, I'm wondering if you would consider returning either the http instance and/or the address the server is listening on. Currently doing this: ```js fastify.listen(process.env.PORT) .then(() => console.info(`Server fired up at http://localhost:${process.env.PORT}`)); ``` Would be nice to just do: ```js fastify.listen(process.env.PORT) .then(url => console.info(`Server fired up at ${url}`)); ```
https://github.com/fastify/fastify/issues/875
https://github.com/fastify/fastify/pull/964
77933c79643c8714479999b81e5c015430a366fa
ce8d439aa004963918d4c97e190c2c9b72036015
"2018-04-09T15:06:30Z"
javascript
"2018-06-18T08:59:50Z"
closed
fastify/fastify
https://github.com/fastify/fastify
872
["fastify.js", "test/listen.test.js"]
Port validation error cannot be caught
**_Warning:_** given the stack trace, I'm not entirely sure it's a Fastify issue. #### Steps to reproduce When awaiting for the `listen()` function with inappropriate port parameter, and inside a proper `try-catch` block, the validation error should be caught. Run the following in node CLI: ```js const fastify = require('fastify') const main = async () => { try { await fastify().listen(-1) console.log('server started') } catch (err) { console.log('error thrown:', err) } } main() ``` #### What was the result you received? You'll get the following output: ```js Promise { <pending>, domain: Domain { domain: null, _events: { error: [Function: debugDomainError] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } > RangeError [ERR_SOCKET_BAD_PORT]: Port should be > 0 and < 65536. Received -1. at Server.listen (net.js:1466:13) ``` #### What did you expect? The `catch()` clause to catch the error: ```js Promise { <pending>, domain: Domain { domain: null, _events: { error: [Function: debugDomainError] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } > error thrown: RangeError: "port" argument must be >= 0 and < 65536 ``` #### Context * *node version*: 8.11.1, 9.11.1 * *fastify version*: 1.2.1 * *os*: Windows 10
https://github.com/fastify/fastify/issues/872
https://github.com/fastify/fastify/pull/873
811eab9a087df317654037971ae9546d7b7f4094
47f295f605d98ddc9dffec3a2ec3cd204b613f0a
"2018-04-07T11:22:06Z"
javascript
"2018-04-08T19:50:38Z"
closed
fastify/fastify
https://github.com/fastify/fastify
868
["fastify.js", "test/404s.test.js", "test/internals/logger.test.js", "test/internals/reply.test.js", "test/logger.test.js"]
"onSend" hook is not being called when handler rejects with {status: 404}
We had a discussion [here](https://github.com/fastify/help/issues/5) Here's the code to reproduce the issue: ```js const fastify = require("fastify"); const autocannon = require('autocannon') let open = 0, count = 0; function connectPg(fastify) { fastify.addHook("preHandler", async function (req, reply) { count += 1; open += 1 }); fastify.addHook("onSend", async (req, res) => { open += -1; }); } const legacyRedirects = async (instance, options, next) => { connectPg(instance); instance.get("/test", async (request, reply) => { if (Math.random() < 0.2) return Promise.reject({ status: 404 }); await new Promise(res => setTimeout(res, Math.random() * 100)) reply.redirect(301, `/other-route`); }); }; const app = fastify({}); app.register(legacyRedirects); app.listen(9393, err => { if (err) throw err; console.log(`server listening on ${app.server.address().port}`); autocannon({ url: `http://localhost:${app.server.address().port}/test`, connections: 10, pipelining: 1, duration: 1 }, (err, res) => { console.log(err, res); console.log("open/count", `${open}/${count}`) app.close(); }) }); ``` Rejecting with `{status: 404}` won't call the "onSend" hook. Any other status I've tested will though.
https://github.com/fastify/fastify/issues/868
https://github.com/fastify/fastify/pull/870
b010287e9183d2b736202979795a77752bf58564
cc2f9c9c6683a46c80ef72b1b81d6ca03dea506d
"2018-03-31T11:43:55Z"
javascript
"2018-04-03T07:33:04Z"
closed
fastify/fastify
https://github.com/fastify/fastify
858
["fastify.d.ts", "test/types/index.ts"]
addContentTypeParser and hasContentTypeParser missing from TypeScript definitions
#### What are you trying to achieve or the steps to reproduce? Being able to write: ```typescript fastify.addContentTypeParser('multipart', () => {}) ``` in a Typescript file #### What was the result you received? `Property addContentTypeParser does not exist on type FastifyInstance`` #### What did you expect? No errors
https://github.com/fastify/fastify/issues/858
https://github.com/fastify/fastify/pull/865
c488cafe497a13c85f9b62a9644cc0f0f4afcaff
470882411f9b2b1a6fd06911ea5a6e2ee7a50ba2
"2018-03-22T06:46:47Z"
javascript
"2018-04-11T06:39:10Z"
closed
fastify/fastify
https://github.com/fastify/fastify
854
["package.json", "test/404s.test.js", "test/405.test.js"]
An in-range update of find-my-way is breaking the build 🚨
☝️ Greenkeeper’s [updated Terms of Service](https://mailchi.mp/ebfddc9880a9/were-updating-our-terms-of-service) will come into effect on April 6th, 2018. ## Version **1.11.0** of [find-my-way](https://github.com/delvedor/find-my-way) was just published. <table> <tr> <th align=left> Branch </th> <td> <a href="/fastify/fastify/compare/greenkeeper%2Ffind-my-way-1.11.0">Build failing 🚨</a> </td> </tr> <tr> <th align=left> Dependency </td> <td> find-my-way </td> </tr> <tr> <th align=left> Current Version </td> <td> 1.10.4 </td> </tr> <tr> <th align=left> Type </td> <td> dependency </td> </tr> </table> This version is **covered** by your **current version range** and after updating it in your project **the build failed**. find-my-way is a direct dependency of this project, and **it is very likely causing it to break**. If other packages depend on yours, this update is probably also breaking those in turn. <details> <summary>Status Details</summary> - ❌ **continuous-integration/appveyor/branch** Waiting for AppVeyor build to complete [Details](https://ci.appveyor.com/project/mcollina/fastify/build/1.0.1404) - ❌ **coverage/coveralls** Coverage pending from Coveralls.io [Details](https://coveralls.io/builds/16068417) - ❌ **continuous-integration/travis-ci/push** The Travis CI build failed [Details](https://travis-ci.org/fastify/fastify/builds/355725212?utm_source=github_status&utm_medium=notification) </details> --- <details> <summary>Release Notes</summary> <strong>v1.11.0</strong> <ul> <li>Support all HTTP methods - <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="304958938" data-permission-text="Issue title is private" data-url="https://github.com/delvedor/find-my-way/issues/72" href="https://urls.greenkeeper.io/delvedor/find-my-way/pull/72">#72</a></li> <li>Internals refactor, better performances - <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="304925413" data-permission-text="Issue title is private" data-url="https://github.com/delvedor/find-my-way/issues/71" href="https://urls.greenkeeper.io/delvedor/find-my-way/pull/71">#71</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 16 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/f476733b7321dad2f5d5232763b52742924bcc98"><code>f476733</code></a> <code>Bumped v1.11.0</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/58691b78bbae0e56784c08070b7c9ed874a19a07"><code>58691b7</code></a> <code>Merge pull request #71 from delvedor/refactor</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/33c769d2cd632cf98c18897fd7fb87ba4a392740"><code>33c769d</code></a> <code>Improved performances of dynamic routes</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/e53ca9c83fb50e01b4619b40c2227345892c4a91"><code>e53ca9c</code></a> <code>Updated benchmark script</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/49cb417a5896859fa3230d9d7841d074a87bdf7c"><code>49cb417</code></a> <code>More strict equality check</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/c70b2e8599262aa4d784f8f50c88ee655cca94ca"><code>c70b2e8</code></a> <code>Fixed regression</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/d426aafab6dec5a90c9de20aaf3648a9407e8b3f"><code>d426aaf</code></a> <code>Added fast-decode-uri-component</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/643ecc9c8073d459a53fe030d68481dfb7056ec8"><code>643ecc9</code></a> <code>Merge branch 'master' into refactor</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/6cb5a1a978443f188345f0e378c4742a757ce38d"><code>6cb5a1a</code></a> <code>Merge pull request #72 from allevo/use-http-methods</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/756a455b6318e8b5ca765958002625400de337d9"><code>756a455</code></a> <code>Add shorthand api for all HTTP methods. Add test. Fix doc</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/81fe80eb246fbbc2a299dbd9106908a7ebe4a218"><code>81fe80e</code></a> <code>Add test. Add docs. Add pre-commit</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/38f7181275f5bdfee6c0eea96c35d103297845f8"><code>38f7181</code></a> <code>Add package-lock-json to gitignore</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/93638b05827c704c439abc7df9dbc9defadd497a"><code>93638b0</code></a> <code>Use http.METHODS</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/47ed6f5a956a86b87278ad74c832f30748c93cc1"><code>47ed6f5</code></a> <code>Updated test</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/b119af801825a804a2431059fde1cdde57022e9d"><code>b119af8</code></a> <code>Updated example</code></li> </ul> <p>There are 16 commits in total.</p> <p>See the <a href="https://urls.greenkeeper.io/delvedor/find-my-way/compare/cc6ac4e5a1b1617ca2d84cce33201f727ae12c8b...f476733b7321dad2f5d5232763b52742924bcc98">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) Bot :palm_tree:
https://github.com/fastify/fastify/issues/854
https://github.com/fastify/fastify/pull/855
67eb3d7ba0cb911d22a504be46ad57b7370a1676
c759af7be4e720bc4fcae3b0c936b938645ddb7e
"2018-03-20T07:20:17Z"
javascript
"2018-03-20T08:50:13Z"
closed
fastify/fastify
https://github.com/fastify/fastify
826
["fastify.js", "lib/logger.js", "package.json", "test/internals/logger.test.js", "test/logger.test.js"]
Logger responseTime is null on 1.0.0-rc.3
on *version 1.0.0-rc.3* the logger responseTime return null. this line return `undefined` instead of the current time https://github.com/fastify/fastify/commit/f545accb2976d54a63a573cc187a0b0472cba972#diff-20da0b6140a4768d182af0d9b185ac28R208 ```js const fastify = Fastify({ logger: true }); ```
https://github.com/fastify/fastify/issues/826
https://github.com/fastify/fastify/pull/827
88397a5f74dbf20951421d74bf95c15838680368
288903a3504c98762005e77c5b100ed272e0d352
"2018-03-03T18:05:02Z"
javascript
"2018-03-04T19:02:54Z"
closed
fastify/fastify
https://github.com/fastify/fastify
825
["test/internals/reply.test.js"]
reply.serialize() is untested
Currently, there is only one test that touches `reply.serialize()` and all it does is check that it's a function. https://github.com/fastify/fastify/blob/bebddc5817d6e23c4a802d9449525f27b618e65a/test/internals/reply.test.js#L22
https://github.com/fastify/fastify/issues/825
https://github.com/fastify/fastify/pull/857
c759af7be4e720bc4fcae3b0c936b938645ddb7e
07cf266265a6ef6e174a707c82972cd8ff6a39f7
"2018-03-03T05:31:59Z"
javascript
"2018-03-24T23:12:51Z"
closed
fastify/fastify
https://github.com/fastify/fastify
824
["package.json"]
An in-range update of find-my-way is breaking the build 🚨
☝️ Greenkeeper’s [updated Terms of Service](https://mailchi.mp/ebfddc9880a9/were-updating-our-terms-of-service) will come into effect on April 6th, 2018. ## Version **1.10.2** of [find-my-way](https://github.com/delvedor/find-my-way) was just published. <table> <tr> <th align=left> Branch </th> <td> <a href="/fastify/fastify/compare/greenkeeper%2Ffind-my-way-1.10.2">Build failing 🚨</a> </td> </tr> <tr> <th align=left> Dependency </td> <td> find-my-way </td> </tr> <tr> <th align=left> Current Version </td> <td> 1.10.1 </td> </tr> <tr> <th align=left> Type </td> <td> dependency </td> </tr> </table> This version is **covered** by your **current version range** and after updating it in your project **the build failed**. find-my-way is a direct dependency of this project, and **it is very likely causing it to break**. If other packages depend on yours, this update is probably also breaking those in turn. <details> <summary>Status Details</summary> - ❌ **continuous-integration/travis-ci/push** The Travis CI build failed [Details](https://travis-ci.org/fastify/fastify/builds/348513203?utm_source=github_status&utm_medium=notification) - βœ… **coverage/coveralls** First build on greenkeeper/find-my-way-1.10.2 at 97.041% [Details](https://coveralls.io/builds/15787770) - ❌ **continuous-integration/appveyor/branch** AppVeyor build failed [Details](https://ci.appveyor.com/project/mcollina/fastify/build/1.0.1351) </details> --- <details> <summary>Release Notes</summary> <strong>v1.10.2</strong> <ul> <li>Fix issue looking up routes that don't exist - <a href="https://urls.greenkeeper.io/delvedor/find-my-way/pull/65" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="301511827" data-permission-text="Issue title is private" data-url="https://github.com/delvedor/find-my-way/issues/65">#65</a></li> <li>Optimized existence checks - <a href="https://urls.greenkeeper.io/delvedor/find-my-way/pull/66" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="301912848" data-permission-text="Issue title is private" data-url="https://github.com/delvedor/find-my-way/issues/66">#66</a></li> </ul> </details> <details> <summary>Commits</summary> <p>The new version differs by 10 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/53ea1b488b48d4530319960562707d1680bf0425"><code>53ea1b4</code></a> <code>Bumped v1.10.2</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/98b47ec5a0a957e41b6b3734ad2c4f64fdae1969"><code>98b47ec</code></a> <code>Merge pull request #66 from delvedor/optimizations</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/10557802e3ef2ecae822a34e156427d4f998c886"><code>1055780</code></a> <code>Optimized existence checks</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/89da9757c20772998297ad25254f018a284e5f5d"><code>89da975</code></a> <code>Merge pull request #65 from nwoltman/fix-wrong-route-same-prefix</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/38cb6deadfe83d79f8fc0e0c37b08704206a156c"><code>38cb6de</code></a> <code>More test</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/257d2f0ad71d522da81943bb4dcb891cbc22df45"><code>257d2f0</code></a> <code>Fix all test cases</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/efb613d201f2ec624fdc97257354285ed62a2ea6"><code>efb613d</code></a> <code>Add failing test</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/cb9e8e516362679d817e40739632d7707c5f78b7"><code>cb9e8e5</code></a> <code>Fix issue looking up routes that don't exist</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/ba04e309b28b64f18fe6a535b6dad5e1ee1f89e8"><code>ba04e30</code></a> <code>Merge pull request #58 from nwoltman/docs-remove-caveat</code></li> <li><a href="https://urls.greenkeeper.io/delvedor/find-my-way/commit/562ba27df42579917ab34008924db282135dd28c"><code>562ba27</code></a> <code>Remove old caveat</code></li> </ul> <p>See the <a href="https://urls.greenkeeper.io/delvedor/find-my-way/compare/b2d8136f132ed5eaac29fc45a007c825a4c53c9c...53ea1b488b48d4530319960562707d1680bf0425">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) Bot :palm_tree:
https://github.com/fastify/fastify/issues/824
https://github.com/fastify/fastify/pull/1799
d48c6a21f21d72b7683808aa88b3fdcd2e0478db
05c0329cce02d3124e868d13c4072b9c6c9981ad
"2018-03-03T01:52:57Z"
javascript
"2019-08-26T09:40:38Z"
closed
fastify/fastify
https://github.com/fastify/fastify
817
[".travis.yml", "appveyor.yml", "package.json"]
drop node 4 support for 1.0.0
Node 4 is going EOL in two months. I think we can stop supporting it right now and not wait for _our_ next LTS cycle. @fastify?
https://github.com/fastify/fastify/issues/817
https://github.com/fastify/fastify/pull/818
9cc9f3502f30f7e06b2476c9acb7c6fc0539e54f
eb24aa7ddce4e1e8a3240619638ee448e838b684
"2018-02-27T20:16:17Z"
javascript
"2018-02-28T13:18:59Z"
closed
fastify/fastify
https://github.com/fastify/fastify
804
[".github/workflows/benchmark-parser.yml", ".github/workflows/benchmark.yml", ".github/workflows/ci.yml", ".github/workflows/coverage-nix.yml", ".github/workflows/coverage-win.yml", ".github/workflows/integration.yml", ".github/workflows/md-lint.yml", ".github/workflows/package-manager-ci.yml"]
HTTP.createServer().on('request', fastify) does not work
Hello, i am just wondering if it is possible to use `fastify` together with `createServer()` from standard Node.js http/https, for example: ```js let server = HTTP.createServer() server.on('request', fastify) // That wont work server.listen(8080) ``` If yes then how can i do it, and if no it would be good to have this functionality. I know that we can do it with `express` and `koa`. Thank you.
https://github.com/fastify/fastify/issues/804
https://github.com/fastify/fastify/pull/5134
c3a9f49d534026eb0305c2948a0d99fc05692f96
396b8b95bf0f1313b9deeb387d68fdc7ffa97abe
"2018-02-21T21:51:26Z"
javascript
"2023-11-01T14:33:04Z"
closed
fastify/fastify
https://github.com/fastify/fastify
794
[".github/workflows/benchmark-parser.yml", ".github/workflows/benchmark.yml", ".github/workflows/ci.yml", ".github/workflows/coverage-nix.yml", ".github/workflows/coverage-win.yml", ".github/workflows/integration.yml", ".github/workflows/md-lint.yml", ".github/workflows/package-manager-ci.yml"]
application/json parser should attach the raw body content
For signature verification purposes, I need the raw unparsed content of the body on a request using application/json. Could either this be added to the built in parser, or could overriding the json parser be supported?
https://github.com/fastify/fastify/issues/794
https://github.com/fastify/fastify/pull/5134
c3a9f49d534026eb0305c2948a0d99fc05692f96
396b8b95bf0f1313b9deeb387d68fdc7ffa97abe
"2018-02-17T21:19:07Z"
javascript
"2023-11-01T14:33:04Z"
closed
fastify/fastify
https://github.com/fastify/fastify
790
["package.json"]
Skip appveyor from greenkeeper
As titled.
https://github.com/fastify/fastify/issues/790
https://github.com/fastify/fastify/pull/1799
d48c6a21f21d72b7683808aa88b3fdcd2e0478db
05c0329cce02d3124e868d13c4072b9c6c9981ad
"2018-02-16T10:54:49Z"
javascript
"2019-08-26T09:40:38Z"
closed
fastify/fastify
https://github.com/fastify/fastify
777
["package.json"]
AssertionError cannot be caught
Good day, I am trying to do some integration testing and have found what I think is a bug somewhere along the lines. I can't seem to catch an `AssertionError` in the code below, it always throws the `AssertionError` also listed below. ```js try { fastify.register( require('fastify-plugin')( function (f, o, next) { next() }, { decorators: { request: ['session'] } } ) ) fastify.listen(0, function (err) { if (err) { console.error('error in listen callback: %s', err.message) } }) } catch (err) { console.error(err.message) } ``` ```bash /Users/charles/Development/node/fastify-auth0/node_modules/fastify/lib/pluginUtils.js:46 assert( ^ AssertionError [ERR_ASSERTION]: The decorator 'session' is not present in Request at decorators.forEach.decorator (/Users/charles/Development/node/fastify-auth0/node_modules/fastify/lib/pluginUtils.js:46:5) at Array.forEach (<anonymous>) at Function._checkDecorators (/Users/charles/Development/node/fastify-auth0/node_modules/fastify/lib/pluginUtils.js:45:14) at Object.checkDecorators (/Users/charles/Development/node/fastify-auth0/node_modules/fastify/lib/pluginUtils.js:39:44) at Object.registerPlugin (/Users/charles/Development/node/fastify-auth0/node_modules/fastify/lib/pluginUtils.js:64:19) at Boot.override (/Users/charles/Development/node/fastify-auth0/node_modules/fastify/fastify.js:327:59) at Plugin.exec (/Users/charles/Development/node/fastify-auth0/node_modules/avvio/plugin.js:36:29) at Boot.loadPlugin (/Users/charles/Development/node/fastify-auth0/node_modules/avvio/plugin.js:120:10) at Task.release (/Users/charles/Development/node/fastify-auth0/node_modules/fastq/queue.js:127:16) at worked (/Users/charles/Development/node/fastify-auth0/node_modules/fastq/queue.js:169:10) at toLoad.finish (/Users/charles/Development/node/fastify-auth0/node_modules/avvio/plugin.js:123:7) at done (/Users/charles/Development/node/fastify-auth0/node_modules/avvio/plugin.js:81:5) at check (/Users/charles/Development/node/fastify-auth0/node_modules/avvio/plugin.js:92:7) at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickDomainCallback (internal/process/next_tick.js:218:9) at Function.Module.runMain (module.js:678:11) ``` * *node version*: 8 * *fastify version*: >=1.0.0-rc.1 * *os*: Mac
https://github.com/fastify/fastify/issues/777
https://github.com/fastify/fastify/pull/1799
d48c6a21f21d72b7683808aa88b3fdcd2e0478db
05c0329cce02d3124e868d13c4072b9c6c9981ad
"2018-02-12T01:00:12Z"
javascript
"2019-08-26T09:40:38Z"
closed
fastify/fastify
https://github.com/fastify/fastify
768
["package.json"]
Move all (?) examples into fastify/example
We have https://github.com/fastify/example repo. Should we use it for keeping the examples? All examples? If yes, we should rethink `npm run bench` script . Please vote! πŸ‘ for moving, πŸ‘Ž for keeping it there. cc @fastify/fastify
https://github.com/fastify/fastify/issues/768
https://github.com/fastify/fastify/pull/4581
c6a40ebe3ec9aaa2886d8ba7646fea88559412f6
2e9526e6245421570a5ef54d3676421f617dc4d7
"2018-02-08T21:30:16Z"
javascript
"2023-02-13T15:35:50Z"
closed
fastify/fastify
https://github.com/fastify/fastify
748
["fastify.js", "test/hooks.test.js", "test/middleware.test.js"]
Consider using `.after()` inside `.addHook` and `.use` calls
Here's a summary of the bug from fastify/fastify-cookie#5: ```js fastify.register(require('fastify-cookie')) fastify.addHook('preHandler', (request, reply, next) => { console.log(request.cookies) // {} - Expected cookies to have been parsed here :( next() }) fastify.get('/', (request, reply) => { console.log(request.cookies) // {foo: 'bar'} - Now the cookies have been parsed reply.send('hello') }) ``` Since plugins are registered asynchronously, the user's call to `fastify.addHook` happens before `fastify-cookie` calls `.addHook`, so even though it looks like the user added their hook after `fastify-cookie`, it actually gets added before the cookie hook. This could be fixed by using `this.after()` inside `.addHook` so that the hook would get added after the plugin's hooks. We already do this for `fastify.route` (which includes the route shorthands) as well as `fastify.setNotFoundHandler`. Note that this change would affect code like this: ```js fastify.addHook('preHandler', function preHandlerA () {}) fastify.register((instance, options, next) => { instance.get('/user', function handler () {}) // Currently: Both preHandlerA and preHandlerB run before the '/user' handler // With .after(): Only preHandlerA runs before the '/user' handler }) fastify.addHook('preHandler', function preHandlerB () {}) ``` I think that using `.after()` inside `.addHook` and `.use` calls would be a good idea because it would make the ordering of hooks and middleware more predictable. Does everyone agree?
https://github.com/fastify/fastify/issues/748
https://github.com/fastify/fastify/pull/771
8aa6b1dfb8b7f0298c72dcf2b8aafcf003a87dfb
4183c3b5fd3f9a0de66674e343b480e32d4e3a74
"2018-02-04T02:08:07Z"
javascript
"2018-02-15T12:30:32Z"
closed
fastify/fastify
https://github.com/fastify/fastify
744
["docs/Server-Methods.md", "fastify.d.ts", "lib/reply.js", "test/500s.test.js", "test/logger.test.js", "test/reply-error.test.js", "test/types/index.ts"]
Accessing the Request object in an error handler
Sometimes it's necessary access the Fastify `request` object inside an error handler ([`fastify.setErrorHandler`](https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md#seterrorhandler)) such as to check request headers. This can currently be done by accessing `reply.request`, but this may not be the best API (will `reply` always have the `request` property in the future?). My question is, should we: **A)** Document `reply.request` or **B)** Change the error handler signature to: `function (error, request, reply) { ... }` My personal preference is B because that seems more future-proof and is closer to the signature of regular handlers. But I'd like to hear what everyone else thinks about this.
https://github.com/fastify/fastify/issues/744
https://github.com/fastify/fastify/pull/745
0986bc408c61c5fb3f36d63e5689f251890b1095
49fbe95f5904fc4da822a704895f9f0ea7469416
"2018-02-02T18:21:21Z"
javascript
"2018-02-02T21:54:34Z"
closed
fastify/fastify
https://github.com/fastify/fastify
723
["docs/Routes.md"]
returning undefined from async/await
#### What are you trying to achieve or the steps to reproduce? According to the documentation, we can declare `async/await` handlers and simply `return` from them. https://www.fastify.io/docs/latest/Routes/#async-await BUT, it appeared that one can not return `undefined` or `return;`, `fastify` will not send this payload to the user. This was already partly touched [here](https://github.com/fastify/fastify/issues/548), so I see the code which does the check, but why? ```javascript const fastify = require("fastify")({ logger: true }); fastify.get(`/works`, async (request, reply) => { console.log("I am here"); return ""; }); fastify.get(`/does-not-work`, async (request, reply) => { console.log("I am here"); return; }); (async function() { try { await fastify.listen(3000); console.log(`🌎 127.0.0.1:3000`); } catch (error) { console.error(error); } })(); ``` Why undefined payload is not considered as real payload? #### What was the result you received? Response is never sent. #### What did you expect? Clean `200` response. #### Context * *node version*: 8 * *fastify version*: >=0.41.0 * *os*: Mac
https://github.com/fastify/fastify/issues/723
https://github.com/fastify/fastify/pull/889
5892d5ea2585624504f190b4cb15d8e4d9c80228
5b6c839549faecabdfda96c0aad2675b40c372c0
"2018-01-29T14:07:22Z"
javascript
"2018-04-18T19:10:48Z"
closed
fastify/fastify
https://github.com/fastify/fastify
707
["docs/Ecosystem.md"]
Support rawBody or override JSON parser
In #643, it was decided to have a separate discussion/PR for supporting ```rawBody```. I would like to start that discussion. An alternative that doesn't increase memory usage is having an option to override the JSON parser for specific routes. I know the fastify community has done a lot of work to make JSON parsing fast which is awesome, but sometimes you just need to do it yourself. Why? Int64 and big decimals. I am working on a JSON API which supports any number regardless of size for specific routes. That number is either stored in Postgres directly or it is used in a SELECT. Either way, Javascript's rounding can screw it up. I also have a use case for storing the raw JSON from the client in the database. I use a custom C/C++ JSON parser to handle the large numbers. Personally I would prefer ```rawBody``` because then I can still use schema validation, etc on the routes. Having to explicitly enable it also makes sense to me since it would increase memory usage.
https://github.com/fastify/fastify/issues/707
https://github.com/fastify/fastify/pull/2342
2ee21f8be33c8d3a10b0a680a5a63cee664b4c85
1d4dcf2bcde46256c72e96c2cafc843a461c721e
"2018-01-23T19:33:27Z"
javascript
"2020-06-24T15:56:36Z"
closed
fastify/fastify
https://github.com/fastify/fastify
700
["docs/Getting-Started.md"]
document that for decorators to work across plugins you have to use fastify-plugin
ref: https://github.com/fastify/fastify/pull/699 (and others)
https://github.com/fastify/fastify/issues/700
https://github.com/fastify/fastify/pull/701
d89079ce3646e98ccc7490cd41b12f23856e5202
f4860bb89754fe6e10cd1d42d8517461cf08b3ef
"2018-01-22T14:47:22Z"
javascript
"2018-01-22T20:57:16Z"
closed
fastify/fastify
https://github.com/fastify/fastify
696
["fastify.js", "test/middleware.test.js"]
Inconsistency between registering hooks and middleware inside a plugin
#### Steps to reproduce ```js const fastifyPlugin = require('fastify-plugin') const fastify = require('fastify')() fastify.get('/', (request, reply) => { console.log('handler') reply.send('OK') }) fastify.register(fastifyPlugin((fastify, options, next) => { fastify.addHook('onRequest', (req, res, next) => { console.log('onRequest', req.url) next() }) fastify.use((req, res, next) => { console.log('middleware', req.url) next() }) next() })) fastify.listen(8080, (err) => { if (err) throw err console.log('Server listening') }) ``` #### What was the result you received? Start the server and navigate to `http://localhost:80/`. You'll see this in your console: ``` $ node index.js Server listening middleware / handler ``` #### What did you expect? Either both the hook and the middleware should run or neither should run. I can open a PR to make it so that middleware are added to routes the same way that hooks are (so that in this example the middleware won't run). I just want to make sure that's the expected functionality. It's a little unclear what should happen because if you add both the hook and the middleware after the handler outside of a plugin: ```js fastify.get('/', (request, reply) => { reply.send('OK') }) fastify.addHook('onRequest', (req, res, next) => { console.log('onRequest', req.url) next() }) fastify.use((req, res, next) => { console.log('middleware', req.url) next() }) ``` then both will run. ``` Server listening onRequest / middleware / handler ```
https://github.com/fastify/fastify/issues/696
https://github.com/fastify/fastify/pull/698
294dbc185a6514caf255bf4eb0f7f3af7b925308
ef2215711ca4e348f91b32c8c413d1779692bebd
"2018-01-21T21:15:36Z"
javascript
"2018-01-23T16:20:31Z"
closed
fastify/fastify
https://github.com/fastify/fastify
686
["docs/Server-Methods.md", "fastify.js", "test/route-prefix.test.js"]
Plugin needs to know its full path
Sometimes a plugin needs to be able to compose the full URL to the handlers it defines. For example, when working with SAML you must tell the remote IdP the callback URL to use when it POSTs back to you. If the SAML communication is implemented in a plugin, then that plugin could be mounted with a prefix that is itself under another prefix. But the plugin only has access to its *immediate* prefix. Example: https://github.com/fastify/fastify/blob/4a5cd18e5bda435548370623034c7cedeafcf55b/test/route-prefix.test.js#L20-L25 On the line where the route gets registered the following is true: 1. `opts.prefix` is set to `/v2` 1. `fastify._routePrefix` is set to `/v1/v2` So let's use the public API: ```js fastify.register(function (instance, opts, next) { instance.register(function (instance, opts, next) { instance.get('/foo', function (req, reply) { const address = instance.server.address() // next line is returning the wrong result reply.send( `url = ${address.addres}:${address.port}${opts.prefix}` ) }) next() }, {prefix: '/v2'}) next() }, {prefix: '/v1'}) ``` I propose that the `instance` should expose a public property that provides the full path, e.g.: ```js fastify.register(function (instance, opts, next) { // 'basePath: /v1' instance.log.debug('basePath: %s', instance.basePath) instance.register(function (instance, opts, next) { // 'basePath: /v1/v2' instance.log.debug('basePath: %s', instance.basePath) next() }, {prefix: '/v2'}) next() }, {prefix: '/v1'}) ```
https://github.com/fastify/fastify/issues/686
https://github.com/fastify/fastify/pull/688
befc4cf806f10874d73a36e0ab2b2b52c8ee8f8f
4e5f833932db0b282f71376ded65b400d98f68fe
"2018-01-19T18:29:28Z"
javascript
"2018-01-20T14:26:11Z"
closed
fastify/fastify
https://github.com/fastify/fastify
677
["docs/Hooks.md", "fastify.js", "lib/handleRequest.js", "package.json", "test/hooks-async.js", "test/hooks.test.js", "test/middleware.test.js"]
End request in async preHandler
Let's assume you have a plugin that supplies a `preHandler` hook. This plugin does some validation of incoming requests and returns an error response (401) if the request fails validation and terminates the request chain. With the traditional interface this looks like: ```js fastify.addHook('preHandler', function (req, reply, next) { if (req.headers['foo'] === foo) return next() req.code(401).send({error: 'nope'}) return }) ``` But what do we do if the hook is an `async` function? ```js fastify.addHook('preHandler', async function (req, reply) { if (req.headers['foo'] === foo) return req.code(401).send({error: 'nope'}) return }) ``` In this case we will get an error informing us that the reply has already been sent because 1. it has and 2. the request continues as if the hook didn't encounter an error *despite* `undefined` being returned. So let's modify it to satisfy the error check: ```js fastify.addHook('preHandler', async function (req, reply) { if (req.headers['foo'] === foo) return req.code(401).send({error: 'nope'}) return Error('make fastify realize an error occurred') }) ``` Oops, we have a new problem. In this case we are creating an unhandled rejection. It seems to me that there is no way to properly terminate a request at the `preHandler` step when using an `async` hook. I think there needs to be a way to do it to be consistent with the traditional interface. Maybe `async` hooks can look for specific return values to determine what to do? For example, maybe this would terminate the request correctly?: ```js fastify.addHook('preHandler', async function (req, reply) { if (req.headers['foo'] === foo) return req.code(401).send({error: 'nope'}) return fastify.TERM_REQ }) ``` #### Context * *node version*: 8 * *fastify version*: 0.39.1 * *os*: Mac
https://github.com/fastify/fastify/issues/677
https://github.com/fastify/fastify/pull/692
500ad8ff391ab2e59145bcc6cb313c057a47c7c3
d89079ce3646e98ccc7490cd41b12f23856e5202
"2018-01-17T20:03:16Z"
javascript
"2018-01-22T20:44:50Z"
closed
fastify/fastify
https://github.com/fastify/fastify
672
["docs/Hooks.md", "lib/reply.js", "test/hooks-async.js", "test/hooks.test.js", "test/internals/handleRequest.test.js", "test/internals/reply.test.js", "test/reply-error.test.js"]
Proposal: Run onSend hooks after serialization
I was recently about to write an `onSend` hook in my application when I realized that my hook would need the serialized payload to work properly. I checked out [`fastify-compress`](https://github.com/fastify/fastify-compress) to see how it handles this problem and found that it [serializes the payload itself](https://github.com/fastify/fastify-compress/blob/671d3731d1e32f5572d52abf1413107850a19fc4/index.js#L103-L105) using `reply.serialize()` if it is not already a stream or string. Unfortunately, that particular solution isn't complete because to be fully compatible with the current version of Fastify it would need to duplicate most of [Fastify's serialization code](https://github.com/fastify/fastify/blob/c76e366b1d1dc4b10ceb679e0a25cf6bc19bb814/lib/reply.js#L140-L159). This means that any `onSend` hook that needs the serialized payload would also need to duplicate Fastify's serialization code, or alternatively, require users to serialize the payload and set the right headers themselves before calling `reply.send()`. It doesn't seem right to put that burden on developers. Additionally, the documentation for [Hooks](https://github.com/fastify/fastify/blob/c76e366b1d1dc4b10ceb679e0a25cf6bc19bb814/docs/Hooks.md) currently includes the following information: > If you are using the onSend hook you can update the payload, for example: ```js fastify.addHook('onSend', (request, reply, payload, next) => { var err = null; payload.hello = 'world' next(err, payload) }) ``` Updating the payload in this way does not seem very useful and could actually be considered bad practice. If anyone needs to modify a payload in that way, they could use a custom serializer or set a response schema to be used by `fast-json-stringify`. With this information in mind, I'd like to propose that the order of serialization and `onSend` hooks be switched so that serialization happens before running the hooks. With this format, `onSend` hooks will receive the serialized payloadβ€”which can still be modified just like it can be now. This will also allow the `onSend` hooks to see the right `Content-Type` header (which is set when the payload is serialized).
https://github.com/fastify/fastify/issues/672
https://github.com/fastify/fastify/pull/689
4e5f833932db0b282f71376ded65b400d98f68fe
c2b86cfd15b6f9f481f9b9ff19fe31200a8179e9
"2018-01-17T00:23:03Z"
javascript
"2018-01-20T16:02:55Z"
closed
fastify/fastify
https://github.com/fastify/fastify
630
["docs/Reference/Reply.md", "lib/errors.js", "lib/reply.js", "lib/symbols.js", "test/internals/reply.test.js", "test/reply-trailers.test.js"]
Support HTTP/1.1 trailers
as titled, I think `reply` might needs some facility to set trailers. It might also be a bad idea, as the actual response is always accessible and they could be set in that way if we want to.
https://github.com/fastify/fastify/issues/630
https://github.com/fastify/fastify/pull/3794
802e3e8935dd8a84e08330faca83b7f7a108dad2
8a1234e79312db25e14a369688a15a8b6c9ead3d
"2018-01-07T11:01:51Z"
javascript
"2022-03-27T14:41:32Z"
closed
fastify/fastify
https://github.com/fastify/fastify
629
["package.json"]
Support 'onClose' without the instance object
if `onClose(func)` is called with a function with 1 parameter, pass the callback and not the instance as the first one. Or the user might find some very hard to debug bugs like: ``` aa Error at fastify (C:\Users\Matteo\Repositories\fastify-http-forward\node_modules\fastify\fastify.js:158:23) at fastify.onClose (C:\Users\Matteo\Repositories\fastify-http-forward\index.js:38:5) at Function._encapsulateTwoParam (C:\Users\Matteo\Repositories\fastify-http-forward\node_modules\avvio\boot.js:328:7) at Boot.closeWithCbOrNextTick (C:\Users\Matteo\Repositories\fastify-http-forward\node_modules\avvio\boot.js:319:7) at release (C:\Users\Matteo\Repositories\fastify-http-forward\node_modules\fastq\queue.js:127:16) at Object.resume (C:\Users\Matteo\Repositories\fastify-http-forward\node_modules\fastq\queue.js:61:7) at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickDomainCallback (internal/process/next_tick.js:218:9) ```
https://github.com/fastify/fastify/issues/629
https://github.com/fastify/fastify/pull/1201
02770849ea15aba175c51f6c9fc4dc95e7518b84
19a7c1212b0945fce241769cf47b197a99f9c32a
"2018-01-07T10:54:22Z"
javascript
"2018-10-05T16:58:35Z"
closed
fastify/fastify
https://github.com/fastify/fastify
623
[".github/workflows/ci.yml"]
Governance model
## Proposal According to the [Contributing](https://github.com/fastify/fastify/blob/aaa892ed8a39c78616801d2bc81d8696f0031549/CONTRIBUTING.md) document, Fastify uses an open governance model. Specifically it states: > Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. Given recent events, my opinion is that this does not work; at least not as it is currently structured. I attempted to make it feasible with [PR 422](https://github.com/fastify/fastify/pull/422), later revised in [PR 614](https://github.com/fastify/fastify/pull/614), but I don't know that it is enough. I think we need to consider a different [governance model](http://oss-watch.ac.uk/resources/governancemodels). I recognize that a "benevolent dictator" model is overly burdensome on a single individual. So I think a committee based model would be a better fit. That is, a designated team, or teams, is allowed to make final decisions on which PRs can be merged. I propose that a single ultimate team, with full merge authority, consist of @delvedor and @mcollina. If other teams are desired then [GitHub's code owners](https://github.com/blog/2392-introducing-code-owners) feature should be investigated. For example, there could be a documentation team wherein all of @fastify/fastify is capable of making a merge to `master`. ## Final Thoughts Fastify is quickly becoming a significant project within the Node.js ecosystem. I think this necessitates the project management be flexible enough to attract contributors, but also strong enough to make unpopular decisions. I have been trying to do my part to make that a reality (see Issue #229), and this is another attempt to do so. Please use this issue to voice your concerns on this matter. ## Collaboration Section *This section left blank for future usage. Ideas/proposals from the discussion may be added here by project owners so that future readings can get important information without reading through every message.*
https://github.com/fastify/fastify/issues/623
https://github.com/fastify/fastify/pull/5301
37b9b3d947d79ae8e5d26e62b9a4b11fb9812c75
eb4ae3cf87e83ef4e00abd66b8fa9009b2efc585
"2018-01-05T13:50:55Z"
javascript
"2024-02-01T14:36:00Z"
closed
fastify/fastify
https://github.com/fastify/fastify
595
["lib/reply.js", "test/reply-error.test.js"]
Response with Content-Type set and object payload hangs in fastify ^0.35.7
```js const fastify = require('fastify') const server = fastify() server.get('/', async (request, reply) => { reply.type('text/html') reply.send(request.req.headers) }).listen(8080) ``` no response and no error
https://github.com/fastify/fastify/issues/595
https://github.com/fastify/fastify/pull/596
34c5f12ac7b6ddede0cb7764e614ad4162afabbc
bfadfd6fd5799016c83eb5a60489a4119e2e21ad
"2017-12-29T13:43:29Z"
javascript
"2018-01-04T08:48:02Z"
closed
fastify/fastify
https://github.com/fastify/fastify
594
["fastify.js", "test/404s.test.js", "test/500s.test.js", "test/custom-parser.test.js", "test/hooks.test.js", "test/middleware.test.js", "test/post.test.js", "test/route.test.js"]
Throw error when manipulating fastify after server was started
As titled. We have to check which interface can be used to modify fastify after start. E.g `setErrorHandler` has no effect after `.listen()` it's novel to inform the developer about that.
https://github.com/fastify/fastify/issues/594
https://github.com/fastify/fastify/pull/671
ade7777aaa9ad5e351734771fe46d18a3b58480d
0300cc2656671ffe5b1c8fa636c79a917acf00df
"2017-12-29T13:29:08Z"
javascript
"2018-01-17T16:30:18Z"
closed
fastify/fastify
https://github.com/fastify/fastify
569
["docs/Ecosystem.md"]
plugin: Support using Boom for errors
Previously, Fastify included built-in support for [Boom errors](https://github.com/hapijs/boom). Issue #542 and PR #558 removed that support in an effort to simplify error handling within the core library. Thus, it would be nice to have a plugin within the ecosystem that provides this functionality. This should be a very easy plugin to create. It merely has to replicate the following code: https://github.com/fastify/fastify/blob/4a6396e8a3f1ba0292f5a52e220122e382e0440f/lib/reply.js#L49-L62
https://github.com/fastify/fastify/issues/569
https://github.com/fastify/fastify/pull/697
934ede1bb4f95e9541df128f408950b25ec3bffc
758acf4d706ca5c2183343ebd592efb178582964
"2017-12-21T14:02:52Z"
javascript
"2018-01-24T13:49:47Z"
closed
fastify/fastify
https://github.com/fastify/fastify
550
["fastify.js", "lib/ContentTypeParser.js", "test/hooks.test.js"]
Certain errors result in request being null
If an error occurs before the Validation part of the lifecycle, `request` is `null` in: + The `onSend` hook ```js fastify.addHook('onSend', function(request, reply, payload, next) { console.log(request) // null }) ``` + Any custom error handler ```js fastify.setErrorHandler(function(err, reply) { console.log(reply.request) // null }) ``` This is very much unexpected in the `onSend` hook and this also makes it more difficult to access the `req` object in the error handler. See PR #551 for a potential fix.
https://github.com/fastify/fastify/issues/550
https://github.com/fastify/fastify/pull/551
b2d9885c1850953de875c46014e38688f014b1f4
0506e7c84dbe3307c35fc5b267b674c00ef7c6ea
"2017-12-17T23:28:42Z"
javascript
"2017-12-18T09:32:19Z"
closed
fastify/fastify
https://github.com/fastify/fastify
548
["lib/handleRequest.js", "test/async-await.js"]
Question about async handlers that call reply.send()
Why is the check implemented [this way](https://github.com/fastify/fastify/blob/67e111e8bc4e5f47d4aa93468a71bccdb8664037/lib/handleRequest.js#L124-L126)? ```js if (payload !== undefined || state.reply.res.statusCode === 204) { state.reply.send() } ``` I would have expected it to be: ```js if (payload !== undefined || !state.reply.sent) { state.reply.send(payload) } ```` I'm mainly concerned because I have a reply decorator that does this: ```js reply.code(204).send(); ``` and if I use that inside an `async` handler, `reply.send()` gets called twice. Plus I feel like it would be a better developer experience to send an empty response if the developer doesn't call `reply.send()` inside a handler that resolves to `undefined` rather than letting the request hang.
https://github.com/fastify/fastify/issues/548
https://github.com/fastify/fastify/pull/549
67e111e8bc4e5f47d4aa93468a71bccdb8664037
9a33533932249788c1cfa5fb978af8e3ca93edbe
"2017-12-17T05:13:24Z"
javascript
"2017-12-18T09:30:16Z"
closed
fastify/fastify
https://github.com/fastify/fastify
543
["fastify.d.ts", "package.json"]
Use http-errors
As titled: http://npm.im/http-errors
https://github.com/fastify/fastify/issues/543
https://github.com/fastify/fastify/pull/1254
fc985a5cf59f47029d161c2e74d29698b054023e
41f71ebbf788f5d168c5e87925c5b2e52a44d0af
"2017-12-13T14:02:22Z"
javascript
"2018-12-12T08:41:37Z"
closed
fastify/fastify
https://github.com/fastify/fastify
540
["fastify.d.ts", "package.json"]
do not JSON.stringify strings by default
Currently we are converting strings to JSON by default, but possibly we should render them as text-plain, without kicking in the serializer.
https://github.com/fastify/fastify/issues/540
https://github.com/fastify/fastify/pull/1254
fc985a5cf59f47029d161c2e74d29698b054023e
41f71ebbf788f5d168c5e87925c5b2e52a44d0af
"2017-12-13T11:03:54Z"
javascript
"2018-12-12T08:41:37Z"
closed
fastify/fastify
https://github.com/fastify/fastify
537
["lib/handleRequest.js", "test/helper.js"]
POST with empty body fails
Fastify fails when handling POST requests with empty body (be it none specified or `content-length: 0`) - `HTTP/1.1 415 Unsupported Media Type`. Is that intended? Or are there any additional steps needed to make it work?
https://github.com/fastify/fastify/issues/537
https://github.com/fastify/fastify/pull/650
e3b8f8e3d1d547f2569da9d4528d0a904c94011b
70707047a531c28f66fd29a685ae35f7764b5f3d
"2017-12-11T22:23:19Z"
javascript
"2018-01-12T09:26:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
525
["package.json"]
ContentType parser API
I think the API for the ContentType Parser is wrong. https://github.com/fastify/fastify/blob/64f03922f49ef4f045b84bbb3832c90b3c1d8cd2/test/custom-parser.test.js#L87-L92 As an example: ```js function customParser (req, done) { jsonParser(req, function (err, body) { if (err) return done(err) done(body) }) } ``` I think this should be: ```js function customParser (req, done) { jsonParser(req, function (err, body) { if (err) return done(err) done(null, body) }) } ``` And we should also support async/await (maybe in the future, dealing with streams with promises is currently very bad): ```js async function customParser (req) { return await jsonParser(req) } ```
https://github.com/fastify/fastify/issues/525
https://github.com/fastify/fastify/pull/1204
dbf99f7768ecb3f77cd402bd39d90044d97ee536
d0b0df29c271c35f8ba41271f93f6a40b9dec733
"2017-12-06T10:15:04Z"
javascript
"2018-10-12T18:27:54Z"
closed
fastify/fastify
https://github.com/fastify/fastify
517
["fastify.d.ts", "package.json"]
health check or status-monitor for fastify
I am struggling to find health check or status-monitor something like [express-status-monitor](https://www.npmjs.com/package/express-status-monitor). How can I achieve the same in fastify.
https://github.com/fastify/fastify/issues/517
https://github.com/fastify/fastify/pull/1254
fc985a5cf59f47029d161c2e74d29698b054023e
41f71ebbf788f5d168c5e87925c5b2e52a44d0af
"2017-12-05T10:36:49Z"
javascript
"2018-12-12T08:41:37Z"
closed
fastify/fastify
https://github.com/fastify/fastify
514
["lib/bin.js", "package.json"]
Consider removal of fastify-cli from main package dependencies
From latest git revision of fastify `npm install --prod` installs 124 packages (15 out of date), 7.2mb. If I remove fastify-cli from package.json, and `npm prune --prod` I'm left with 47 packages (4 out of date), 5.0MB. I'm less concerned about the install size, more concerned with the ability to identify important dependencies. Issues with the 47 packages are far more important than security in the other 78 packages.
https://github.com/fastify/fastify/issues/514
https://github.com/fastify/fastify/pull/547
dce12809498bf235219a6539f4768f747e864480
7cca849de5a8d4a430de9c2468f13f3d6b572bf4
"2017-12-05T06:41:31Z"
javascript
"2017-12-21T08:27:49Z"
closed
fastify/fastify
https://github.com/fastify/fastify
508
["package.json"]
Static url and parametric url
url: '/s' url: '/:filename' Then both urls cannot match all urls beginning with 's' Such as '/styles.css'
https://github.com/fastify/fastify/issues/508
https://github.com/fastify/fastify/pull/518
fed0e4b6fa07542db07ea3b796d38872805583f6
0c5b2ec4d0292f3e26e1ae04b41462390f1f7f1e
"2017-12-03T06:24:07Z"
javascript
"2017-12-05T11:15:23Z"
closed
fastify/fastify
https://github.com/fastify/fastify
501
["fastify.js", "test/listen.test.js"]
fastify.listen handles null cb inconsistently.
fastify.listen has two ways to call cb, directly from fastify.ready or through the `wrap` function called by server.listen. We should just always use the `wrap` so we consistently support fastify.listen(0) - without an address or callback. The wrap function removes itself from the `error` event listener, this is harmless in the path where the callback to fastify.ready has not yet added the `error` event listener.
https://github.com/fastify/fastify/issues/501
https://github.com/fastify/fastify/pull/502
7ea405de387e1102914fa5ad76f14b6157bea5d8
d3518f04430156d03d48f9c07b38f7ed6081dfb4
"2017-11-30T16:10:29Z"
javascript
"2017-12-05T21:58:54Z"
closed
fastify/fastify
https://github.com/fastify/fastify
500
["lib/reply.js", "test/reply-code.test.js"]
Using REST with Socket - already listening!?
I guess would require two separate instances of `fastify` then? ```js const { fastify } = require('./socket-conn') let fastSocket fastify.ready(() => { console.log('fastify ready: open socket conn') fastify.ws .on('connection', socket => { console.log('connection', { socket }) fastSocket = socket socket.on('message', msg => socket.send(msg)) // Creates an echo server }) }) fastify.listen(34567) // setup routes fastify.listen(3000, err => { if (err) throw err console.log(`server listening on ${fastify.server.address().port}`) }) ```
https://github.com/fastify/fastify/issues/500
https://github.com/fastify/fastify/pull/5056
16859bb0ca643b9e34be6fa4bff4a4ff9efa8289
cefe85d16e378a04b3e38557c6e81e4eda61d363
"2017-11-30T07:10:55Z"
javascript
"2023-10-04T07:57:23Z"
closed
fastify/fastify
https://github.com/fastify/fastify
491
["docs/Getting-Started.md", "docs/Plugins-Guide.md", "docs/Server-Methods.md", "fastify.js", "package.json", "test/ajv-options.test.js", "test/decorator.test.js", "test/listen.test.js", "test/throw.test.js"]
avvio says it's already booted before `fastify.listen` is invoked
```js 'use strict' const fastify = require('fastify')() const fp = require('fastify-plugin') const plugin1 = fp(function plugin1(instance, opts, next) { instance.decorate('plugin1', true) next() }) const plugin2 = fp(function plugin2(instance, opts, next) { instance.decorate('plugin2', true) next() }) const plugin3 = fp(function plugin3(instance, opts, next) { instance.decorate('plugin3', true) instance.get('/', (req, reply) => reply.send('plugin3')) next() }) async function doThings () { fastify.register(plugin1).register(plugin2) return true } doThings() .then(() => { fastify .register(plugin3) .listen(3000) }) .catch((err) => { console.error(err) }) ``` If you run that, you'll get: ``` Error: root plugin has already booted at Boot._init (/private/tmp/26/node_modules/avvio/boot.js:125:11) at Boot._addPlugin (/private/tmp/26/node_modules/avvio/boot.js:180:8) at Boot.use (/private/tmp/26/node_modules/avvio/boot.js:160:10) at Function.server.(anonymous function) [as register] (/private/tmp/26/node_modules/avvio/boot.js:30:14) at doThings.then (/private/tmp/26/index.js:30:8) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:678:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3 ``` My guess is this is due to: https://github.com/mcollina/avvio/blob/6d7554cfe4113985609b33e531f60ba72d36edf3/plugin.js#L83-L99 I most assuredly think that Fastify should allow registrations up until the point `.listen()` is invoked.
https://github.com/fastify/fastify/issues/491
https://github.com/fastify/fastify/pull/561
d740a15f40a301c0dfc5fed0b168d6a0d40004d4
6dae0b41ff247aaea734b2cfb25813508bfc15d3
"2017-11-26T17:56:50Z"
javascript
"2017-12-22T15:24:23Z"
closed
fastify/fastify
https://github.com/fastify/fastify
460
["docs/Plugins.md", "fastify.d.ts", "package.json", "test/register.test.js", "test/types/index.ts"]
remove callback from register, and remove error from .after()
Currently the only way to handle specific error handling and keep booting is by specifying `.after()`. However, this is very subtle and it can lead to complex side effects. I think we should remove this feature: if a plugin errors, the whole loading errors and there is no way to handle that plugin specifics.
https://github.com/fastify/fastify/issues/460
https://github.com/fastify/fastify/pull/651
53a984bad4806c5063c4536679da701c55f65e2f
338c24299bdf7739e40130ab89e0a947ad77fafc
"2017-11-12T23:04:02Z"
javascript
"2018-01-12T14:49:34Z"
closed
fastify/fastify
https://github.com/fastify/fastify
450
["lib/handleRequest.js", "test/helper.js"]
POST returning error Unsupported Media Type 415
Environment: 1. MacOS Sierra 10.12.6 2. NodeJS 8.9.1 Step to reproduce: 1. Pull and clone latest version or this repo 2. Run `node examples/example.js` 3. Open new terminal and try to hit POST endpoint ```shell $ curl -X POST "http://localhost:3000/" -H "accept: application/json" {"error":"Unsupported Media Type","message":"","statusCode":415}% ``` <img width="438" alt="screen shot 2017-11-10 at 7 32 26 pm" src="https://user-images.githubusercontent.com/5300674/32658718-ee4a9020-c64d-11e7-8cd0-c299a4bc2c74.png"> Any MIME type `Accept: */*` still error <img width="400" alt="screen shot 2017-11-10 at 7 45 21 pm" src="https://user-images.githubusercontent.com/5300674/32659138-cf9ea740-c64f-11e7-8dd3-0d81354e800f.png"> Expected Result: I should see `{ hello: 'world' }` from fastify `examples/example.js` https://github.com/fastify/fastify/blob/master/examples/example.js#L43
https://github.com/fastify/fastify/issues/450
https://github.com/fastify/fastify/pull/650
e3b8f8e3d1d547f2569da9d4528d0a904c94011b
70707047a531c28f66fd29a685ae35f7764b5f3d
"2017-11-10T12:32:56Z"
javascript
"2018-01-12T09:26:20Z"
closed
fastify/fastify
https://github.com/fastify/fastify
445
["lib/handleRequest.js", "test/internals/handleRequest.test.js"]
request is undefined in onSend Hook on post request without body
When you send a post request without body, in the `onSend` Hook `undefined` is being passed as `request`. I think the request should be defined in this case (Or if that is not possible documented that the `request` may be `undefined`). I didn't find the reason for this, but I wrote a test that reproduces the problem. I hope it helps: ```js 'use strict' const t = require('tap') const test = t.test const sget = require('simple-get').concat test('request should be defined in onSend Hook', t => { t.plan(3) const fastify = require('..')() fastify.register(plugin) function plugin (fastify, opts, next) { fastify.addHook('onSend', (request, reply, payload, done) => { if (!request) { reply.code(500) } done() }); next() } plugin[Symbol.for('skip-override')] = true fastify.post('/', (request, reply) => { reply.send(200) }) fastify.listen(0, err => { fastify.server.unref() t.error(err) sget({ method: 'POST', url: 'http://localhost:' + fastify.server.address().port, headers: { 'content-type': 'application/json' } }, (err, response, body) => { t.error(err) t.strictEqual(response.statusCode, 422) }) }) }) ```
https://github.com/fastify/fastify/issues/445
https://github.com/fastify/fastify/pull/455
49bdad9d2e3b2e7f292ecf5d327700f870179af6
609c6be15401bb36a424f4161879274058afa25a
"2017-11-08T19:35:16Z"
javascript
"2017-11-15T11:47:40Z"
closed
fastify/fastify
https://github.com/fastify/fastify
417
["docs/Ecosystem.md"]
plugin to return 503s if the server is under too much pressure
These are the equivalent for hapi `load.maxHeapUsedBytes`, `load.maxRssBytes` and `load. maxEventLoopDelay`. For the latter, the plugin should use https://github.com/mcollina/loopbench.
https://github.com/fastify/fastify/issues/417
https://github.com/fastify/fastify/pull/420
431713bd877701d0f584df5ec11f3bc1b7f43656
5572151f255a1edebf00aea4182b9f2a0358b006
"2017-10-31T17:57:16Z"
javascript
"2017-11-01T11:10:15Z"
closed
fastify/fastify
https://github.com/fastify/fastify
409
["lib/reply.js", "test/hooks.test.js"]
throws in `onSend` hook never come back
`onSend` hook may has a cycle execution issue when calling `next(new Error('some error'))`. For example: ```js fastify.addHook('onSend', function (request, reply, payload, next) { next(new Error('some error')); }) fastify.get('/', function (request, reply) { // it will never get here. }) ``` if we start a `GET /` request, it'll timeout As the current execution sequence is: `onSend next(some error)` -> `wrapOnSendEnd` -> `onSendEnd` -> `handleError` -> `onSend hook` If `onSend` throws error again, the upper execution will start again. Create a PR #410
https://github.com/fastify/fastify/issues/409
https://github.com/fastify/fastify/pull/410
bbcf377e851a51f15c6d54fc4b149212bcd64053
3fdbcaa77b0ba6444ffbcc87120896ae5911bbb6
"2017-10-31T00:21:48Z"
javascript
"2017-10-31T10:07:26Z"
closed
fastify/fastify
https://github.com/fastify/fastify
402
[".github/workflows/benchmark.yml", ".github/workflows/coverage-nix.yml", ".github/workflows/coverage-win.yml", ".github/workflows/package-manager-ci.yml"]
How to throw 404 error in router?
I've setup a 404 handler with `setNotFoundHandler` ``` fastify.setNotFoundHandler((request, reply) => { reply.code(404).type('text/html').send('Not Found') }) ``` Now my question is, how can I throw a 404 error in router to use this handler? ``` fastify.get('/:uid', async (request, reply) => { const user = await User.findById(request.params.uid) if (!user) { // ?? how can I throw a 404 error here to use the previous 404 handler? } }) ```
https://github.com/fastify/fastify/issues/402
https://github.com/fastify/fastify/pull/3736
4635d4bc6c25832819c1f7baa62a96ee81dde7fb
2f3aced8b8d4317f8b41853a562205624e8f611a
"2017-10-30T08:01:21Z"
javascript
"2022-03-17T10:41:00Z"
closed
fastify/fastify
https://github.com/fastify/fastify
401
["docs/Reply.md", "lib/reply.js", "test/async-await.js", "test/reply-error.test.js"]
Custom error statusCode
(Apologies for the simple question. I'm completely new to Fastify and could not yet find the answer in the docs/examples/issues/source.) ## Question Can a thrown Error instance set the outgoing HTTP status code? ## Use Cases - Output specific status codes with convenient error throwing from async functions. - https://www.npmjs.com/package/http-errors ## Example ```js const fastify = require('fastify')({ logger: true }) fastify.get('/', async function (request, reply) { const error = new Error() error.message = 'This is the message' error.statusCode = 404 error.error = 'This is the error' throw error }) fastify.listen(3000, function (err) { if (err) throw err console.log(`server listening on ${fastify.server.address().port}`) }) ``` ## Actual Output ``` $ curl --verbose http://[::1]:3000/ * Trying ::1... * TCP_NODELAY set * Connected to ::1 (::1) port 3000 (#0) > GET / HTTP/1.1 > Host: [::1]:3000 > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 500 Internal Server Error < Content-Type: application/json < Content-Length: 82 < Date: Mon, 30 Oct 2017 04:17:12 GMT < Connection: keep-alive < * Connection #0 to host ::1 left intact {"error":"Internal Server Error","message":"This is the message","statusCode":500} ``` ## Expected Output ``` < HTTP/1.1 404 Internal Server Error [...] {"error":"Internal Server Error","message":"This is the message","statusCode":404} ```
https://github.com/fastify/fastify/issues/401
https://github.com/fastify/fastify/pull/404
71b6f91b42b39c75495abfc442f4481b0bd230ad
25e33e4265b73b67669825a9a0d76d1afb91d80e
"2017-10-30T04:20:07Z"
javascript
"2017-10-30T15:12:02Z"
closed
fastify/fastify
https://github.com/fastify/fastify
392
["package.json"]
How to get an fastify instance in the route handler?
```js const handler = async (req, replay) => { // `fastify` from where? const client = await fastify.pg.connect() } fastify.get('/', options, handler) ```
https://github.com/fastify/fastify/issues/392
https://github.com/fastify/fastify/pull/2540
31b7c4f4b12c4b37c874ed5fd03d04fcd35addfb
cfb425ac19a6c4b15d86e11254cbd9e76dd1216c
"2017-10-26T22:12:39Z"
javascript
"2020-09-07T18:15:22Z"
closed
fastify/fastify
https://github.com/fastify/fastify
378
[".gitignore", "fastify.d.ts", "test/types/index.ts"]
How do I use Https through typescript?
https://github.com/fastify/fastify/issues/355 const opt: fastify.ServerOptions = { https: false --> boolean }; const server: fastify.FastifyInstance = fastify(opt); js: const fastify = require('fastify')({ https: { key: fs.readFileSync(path.join(__dirname, 'file.key')), cert: fs.readFileSync(path.join(__dirname, 'file.cert')) } })
https://github.com/fastify/fastify/issues/378
https://github.com/fastify/fastify/pull/383
f3e5344c9a8e0bd2441d773e4462eff815df76d6
da4e1052192dd6d178c306b074c3bbf7fbc224d5
"2017-10-24T07:12:46Z"
javascript
"2017-10-26T15:05:08Z"
closed
fastify/fastify
https://github.com/fastify/fastify
336
["package.json"]
Make architectural recommendation
For some of the dev, those principles are standard refer to testability and modularity but we should definitely document this. We can adapt this for fastify and prepare some nice slides. I like the picture. https://github.com/kimmobrunfeldt/express-example
https://github.com/fastify/fastify/issues/336
https://github.com/fastify/fastify/pull/2540
31b7c4f4b12c4b37c874ed5fd03d04fcd35addfb
cfb425ac19a6c4b15d86e11254cbd9e76dd1216c
"2017-10-09T10:30:33Z"
javascript
"2020-09-07T18:15:22Z"
closed
fastify/fastify
https://github.com/fastify/fastify
272
["docs/Routes.md", "fastify.js", "lib/handleRequest.js", "test/async-await.js", "test/listen.test.js"]
fastify.listen crashes if callback not provided
In v0.28 if no callback function is provided to `fastify.listen` it throws error ``` const fastify = require('fastify')() fastify.get('/', function(request, reply) { reply.send({homepage: true}) }); fastify.listen(3000) ``` https://github.com/fastify/fastify/commit/4d6baea011dbb6e6852e2523fac7cad71bb3360d changed the behavior (wrap always requires _cb to be provided). I was handling server error differently, so I'm not sure if it's the best solution to require callback. --- Here's what I was doing: ```javascript fastify.server.on('error', onError) fastify.server.on('listening', onMessage) // ... fastify.listen(3000) ```
https://github.com/fastify/fastify/issues/272
https://github.com/fastify/fastify/pull/273
ed2e1afc0e163e8f27da16a92668a3ec8e5c36a6
4ae1654b9fd49a80142e211bf1ce29a4be73224f
"2017-09-21T08:32:30Z"
javascript
"2017-09-21T08:46:44Z"