fastify 5.9.0 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/PROJECT_CHARTER.md +1 -1
  2. package/README.md +7 -10
  3. package/build/build-validation.js +2 -2
  4. package/docs/Guides/Delay-Accepting-Requests.md +1 -1
  5. package/docs/Guides/Ecosystem.md +10 -7
  6. package/docs/Guides/Getting-Started.md +2 -2
  7. package/docs/Guides/Migration-Guide-V4.md +2 -2
  8. package/docs/Guides/Migration-Guide-V5.md +1 -1
  9. package/docs/Guides/Plugins-Guide.md +1 -1
  10. package/docs/Guides/Prototype-Poisoning.md +3 -3
  11. package/docs/Guides/Serverless.md +6 -13
  12. package/docs/Guides/Style-Guide.md +1 -1
  13. package/docs/Reference/Errors.md +2 -0
  14. package/docs/Reference/Hooks.md +1 -1
  15. package/docs/Reference/Logging.md +3 -0
  16. package/docs/Reference/Request.md +2 -2
  17. package/docs/Reference/Server.md +107 -8
  18. package/docs/Reference/Type-Providers.md +24 -4
  19. package/docs/Reference/TypeScript.md +3 -3
  20. package/docs/Reference/Warnings.md +4 -0
  21. package/fastify.d.ts +5 -0
  22. package/fastify.js +22 -22
  23. package/lib/content-type-parser.js +1 -11
  24. package/lib/content-type.js +34 -1
  25. package/lib/context.js +0 -3
  26. package/lib/error-handler.js +7 -26
  27. package/lib/errors.js +7 -0
  28. package/lib/four-oh-four.js +8 -10
  29. package/lib/handle-request.js +2 -1
  30. package/lib/log-controller.js +169 -0
  31. package/lib/logger-factory.js +25 -4
  32. package/lib/reply.js +35 -44
  33. package/lib/req-id-gen-factory.js +4 -1
  34. package/lib/request.js +3 -3
  35. package/lib/route.js +27 -35
  36. package/lib/symbols.js +1 -1
  37. package/lib/validation.js +9 -0
  38. package/lib/warnings.js +19 -1
  39. package/package.json +3 -3
  40. package/test/content-type.test.js +20 -0
  41. package/test/genReqId.test.js +24 -0
  42. package/test/hooks.test.js +71 -0
  43. package/test/internals/errors.test.js +1 -1
  44. package/test/internals/logger.test.js +322 -0
  45. package/test/internals/reply.test.js +35 -4
  46. package/test/internals/request.test.js +10 -7
  47. package/test/logger/logging.test.js +40 -1
  48. package/test/stream.4.test.js +2 -2
  49. package/test/trust-proxy.test.js +49 -30
  50. package/types/errors.d.ts +1 -0
  51. package/types/instance.d.ts +2 -0
  52. package/types/logger.d.ts +22 -0
@@ -3,6 +3,7 @@
3
3
  const { test } = require('node:test')
4
4
  const Fastify = require('../..')
5
5
  const loggerUtils = require('../../lib/logger-factory')
6
+ const { createLogController, LogController } = require('../../lib/logger-factory')
6
7
  const { serializers } = require('../../lib/logger-pino')
7
8
 
8
9
  test('time resolution', t => {
@@ -142,6 +143,327 @@ test('The logger should error if both stream and file destination are given', t
142
143
  }
143
144
  })
144
145
 
146
+ test('LogController defaults', t => {
147
+ t.plan(3)
148
+ const dispatcher = new LogController()
149
+ t.assert.strictEqual(dispatcher.disableRequestLogging, false)
150
+ t.assert.strictEqual(dispatcher.requestIdLogLabel, 'reqId')
151
+ t.assert.strictEqual(dispatcher.isLogDisabled({}), false)
152
+ })
153
+
154
+ test('LogController with custom options', t => {
155
+ t.plan(2)
156
+ const dispatcher = new LogController({
157
+ disableRequestLogging: true,
158
+ requestIdLogLabel: 'traceId'
159
+ })
160
+ t.assert.strictEqual(dispatcher.disableRequestLogging, true)
161
+ t.assert.strictEqual(dispatcher.requestIdLogLabel, 'traceId')
162
+ })
163
+
164
+ test('LogController with function disableRequestLogging', t => {
165
+ t.plan(2)
166
+ const dispatcher = new LogController({
167
+ disableRequestLogging: (req) => req.skip === true
168
+ })
169
+ t.assert.strictEqual(dispatcher.isLogDisabled({ skip: true }), true)
170
+ t.assert.strictEqual(dispatcher.isLogDisabled({ skip: false }), false)
171
+ })
172
+
173
+ test('requestCompleted should not log when logging is disabled (boolean)', t => {
174
+ t.plan(1)
175
+ const logController = new LogController({ disableRequestLogging: true })
176
+ const log = {
177
+ error: () => { t.assert.fail('error should not be called') },
178
+ info: () => { t.assert.fail('info should not be called') }
179
+ }
180
+ const request = {}
181
+ const reply = { request, log }
182
+ logController.requestCompleted(new Error('test'), request, reply)
183
+ t.assert.ok(true, 'logger was not called')
184
+ })
185
+
186
+ test('requestCompleted should not log when logging is disabled (function)', t => {
187
+ t.plan(1)
188
+ const logController = new LogController({ disableRequestLogging: () => true })
189
+ const log = {
190
+ error: () => { t.assert.fail('error should not be called') },
191
+ info: () => { t.assert.fail('info should not be called') }
192
+ }
193
+ const request = {}
194
+ const reply = { request, log }
195
+ logController.requestCompleted(new Error('test'), request, reply)
196
+ t.assert.ok(true, 'logger was not called')
197
+ })
198
+
199
+ test('requestCompleted should log error when err is present', t => {
200
+ t.plan(1)
201
+ const logController = new LogController({ disableRequestLogging: false })
202
+ const err = new Error('test')
203
+ const log = {
204
+ error: (data, msg) => {
205
+ t.assert.strictEqual(msg, 'request errored')
206
+ }
207
+ }
208
+ const request = {}
209
+ const reply = { request, log, elapsedTime: 42 }
210
+ logController.requestCompleted(err, request, reply)
211
+ })
212
+
213
+ test('requestCompleted should log info when no error', t => {
214
+ t.plan(1)
215
+ const logController = new LogController({ disableRequestLogging: false })
216
+ const log = {
217
+ info: (data, msg) => {
218
+ t.assert.strictEqual(msg, 'request completed')
219
+ }
220
+ }
221
+ const request = {}
222
+ const reply = { request, log, elapsedTime: 42 }
223
+ logController.requestCompleted(null, request, reply)
224
+ })
225
+
226
+ test('defaultErrorLog should not log when logging is disabled (boolean)', t => {
227
+ t.plan(1)
228
+ const logController = new LogController({ disableRequestLogging: true })
229
+ const log = {
230
+ info: () => { t.assert.fail('info should not be called') },
231
+ error: () => { t.assert.fail('error should not be called') }
232
+ }
233
+ const request = {}
234
+ const reply = { request, log, statusCode: 404 }
235
+ logController.defaultErrorLog(new Error('not found'), request, reply)
236
+ t.assert.ok(true, 'logger was not called')
237
+ })
238
+
239
+ test('defaultErrorLog should not log when logging is disabled (function)', t => {
240
+ t.plan(1)
241
+ const logController = new LogController({ disableRequestLogging: () => true })
242
+ const log = {
243
+ info: () => { t.assert.fail('info should not be called') },
244
+ error: () => { t.assert.fail('error should not be called') }
245
+ }
246
+ const request = {}
247
+ const reply = { request, log, statusCode: 404 }
248
+ logController.defaultErrorLog(new Error('not found'), request, reply)
249
+ t.assert.ok(true, 'logger was not called')
250
+ })
251
+
252
+ test('defaultErrorLog should log info for 4xx errors', t => {
253
+ t.plan(1)
254
+ const logController = new LogController({ disableRequestLogging: false })
255
+ const err = new Error('not found')
256
+ const log = {
257
+ info: (data, msg) => {
258
+ t.assert.strictEqual(msg, 'not found')
259
+ }
260
+ }
261
+ const request = {}
262
+ const reply = { request, log, statusCode: 404 }
263
+ logController.defaultErrorLog(err, request, reply)
264
+ })
265
+
266
+ test('defaultErrorLog should log error for 5xx errors', t => {
267
+ t.plan(1)
268
+ const logController = new LogController({ disableRequestLogging: false })
269
+ const err = new Error('internal error')
270
+ const log = {
271
+ error: (data, msg) => {
272
+ t.assert.strictEqual(msg, 'internal error')
273
+ }
274
+ }
275
+ const request = {}
276
+ const reply = { request, log, statusCode: 500 }
277
+ logController.defaultErrorLog(err, request, reply)
278
+ })
279
+
280
+ test('writeHeadError should not log when logging is disabled (boolean)', t => {
281
+ t.plan(1)
282
+ const logController = new LogController({ disableRequestLogging: true })
283
+ const log = {
284
+ warn: () => { t.assert.fail('warn should not be called') }
285
+ }
286
+ const request = {}
287
+ const reply = { request, log }
288
+ logController.writeHeadError(new Error('write head failed'), request, reply)
289
+ t.assert.ok(true, 'logger was not called')
290
+ })
291
+
292
+ test('writeHeadError should not log when logging is disabled (function)', t => {
293
+ t.plan(1)
294
+ const logController = new LogController({ disableRequestLogging: () => true })
295
+ const log = {
296
+ warn: () => { t.assert.fail('warn should not be called') }
297
+ }
298
+ const request = {}
299
+ const reply = { request, log }
300
+ logController.writeHeadError(new Error('write head failed'), request, reply)
301
+ t.assert.ok(true, 'logger was not called')
302
+ })
303
+
304
+ test('writeHeadError should log warn with error message', t => {
305
+ t.plan(2)
306
+ const logController = new LogController({ disableRequestLogging: false })
307
+ const error = new Error('write head failed')
308
+ const request = {}
309
+ const reply = {
310
+ request,
311
+ log: {
312
+ warn: (data, msg) => {
313
+ t.assert.strictEqual(msg, 'write head failed')
314
+ t.assert.strictEqual(data.err, error)
315
+ }
316
+ }
317
+ }
318
+ logController.writeHeadError(error, request, reply)
319
+ })
320
+
321
+ test('serializerError should not log when logging is disabled (boolean)', t => {
322
+ t.plan(1)
323
+ const logController = new LogController({ disableRequestLogging: true })
324
+ const log = {
325
+ error: () => { t.assert.fail('error should not be called') }
326
+ }
327
+ const request = {}
328
+ const reply = { request, log }
329
+ logController.serializerError(new Error('serializer failed'), request, reply, { statusCode: 500 })
330
+ t.assert.ok(true, 'logger was not called')
331
+ })
332
+
333
+ test('serializerError should not log when logging is disabled (function)', t => {
334
+ t.plan(1)
335
+ const logController = new LogController({ disableRequestLogging: () => true })
336
+ const log = {
337
+ error: () => { t.assert.fail('error should not be called') }
338
+ }
339
+ const request = {}
340
+ const reply = { request, log }
341
+ logController.serializerError(new Error('serializer failed'), request, reply, { statusCode: 500 })
342
+ t.assert.ok(true, 'logger was not called')
343
+ })
344
+
345
+ test('serializerError should log error with status code', t => {
346
+ t.plan(2)
347
+ const logController = new LogController({ disableRequestLogging: false })
348
+ const err = new Error('serializer failed')
349
+ const request = {}
350
+ const reply = {
351
+ request,
352
+ log: {
353
+ error: (data, msg) => {
354
+ t.assert.strictEqual(msg, 'The serializer for the given status code failed')
355
+ t.assert.strictEqual(data.statusCode, 500)
356
+ }
357
+ }
358
+ }
359
+ logController.serializerError(err, request, reply, { statusCode: 500 })
360
+ })
361
+
362
+ test('createLogController should use LogController instance directly', t => {
363
+ t.plan(2)
364
+ const custom = new LogController({ disableRequestLogging: true, requestIdLogLabel: 'traceId' })
365
+ const dispatcher = createLogController({ logController: custom })
366
+ t.assert.strictEqual(dispatcher, custom)
367
+ t.assert.strictEqual(dispatcher.requestIdLogLabel, 'traceId')
368
+ })
369
+
370
+ test('createLogController should create default when no instance provided', t => {
371
+ t.plan(2)
372
+ const dispatcher = createLogController({ disableRequestLogging: false, requestIdLogLabel: 'reqId' })
373
+ t.assert.ok(dispatcher instanceof LogController)
374
+ t.assert.strictEqual(dispatcher.requestIdLogLabel, 'reqId')
375
+ })
376
+
377
+ test('createLogController should throw on invalid type', t => {
378
+ t.plan(1)
379
+ t.assert.throws(() => {
380
+ createLogController({ disableRequestLogging: false, logController: 'bad' })
381
+ }, { code: 'FST_ERR_LOG_INVALID_LOG_CONTROLLER' })
382
+ })
383
+
384
+ test('createLogController should throw when plain object is provided', t => {
385
+ t.plan(1)
386
+ t.assert.throws(() => {
387
+ createLogController({ disableRequestLogging: false, logController: { incomingRequest: () => { } } })
388
+ }, { code: 'FST_ERR_LOG_INVALID_LOG_CONTROLLER' })
389
+ })
390
+
391
+ test('createLogController should accept null', t => {
392
+ t.plan(1)
393
+ const logController = createLogController({ disableRequestLogging: false, logController: null })
394
+ t.assert.ok(logController)
395
+ })
396
+
397
+ test('LogController subclass should work', t => {
398
+ t.plan(2)
399
+
400
+ class MyDispatcher extends LogController {
401
+ constructor () {
402
+ super({ requestIdLogLabel: 'traceId' })
403
+ }
404
+
405
+ incomingRequest (request, reply, metadata) {
406
+ t.assert.ok(true, 'custom incomingRequest called')
407
+ }
408
+ }
409
+
410
+ const dispatcher = new MyDispatcher()
411
+ t.assert.strictEqual(dispatcher.requestIdLogLabel, 'traceId')
412
+ dispatcher.incomingRequest({})
413
+ })
414
+
415
+ test('LogController subclass keeps defaults for non-overridden methods', t => {
416
+ t.plan(1)
417
+
418
+ class MyDispatcher extends LogController {
419
+ incomingRequest () { }
420
+ }
421
+
422
+ const dispatcher = new MyDispatcher()
423
+ const log = {
424
+ info: (data, msg) => {
425
+ t.assert.strictEqual(msg, 'request completed')
426
+ }
427
+ }
428
+ const request = {}
429
+ const reply = { request, log, elapsedTime: 42 }
430
+ dispatcher.requestCompleted(null, request, reply)
431
+ })
432
+
433
+ test('serviceUnavailable should log with logger and receive server', t => {
434
+ t.plan(2)
435
+ const dispatcher = new LogController()
436
+ const fakeLogger = {
437
+ info: (data, msg) => {
438
+ t.assert.deepStrictEqual(data, { res: { statusCode: 503 } })
439
+ t.assert.strictEqual(msg, 'request aborted - refusing to accept new requests as server is closing')
440
+ }
441
+ }
442
+ const fakeServer = { name: 'test-server' }
443
+ dispatcher.serviceUnavailable(fakeLogger, fakeServer)
444
+ })
445
+
446
+ test('serviceUnavailable subclass can use server', t => {
447
+ t.plan(1)
448
+
449
+ const fakeServer = { name: 'test-server' }
450
+
451
+ class MyDispatcher extends LogController {
452
+ serviceUnavailable (logger, server) {
453
+ t.assert.strictEqual(server, fakeServer)
454
+ }
455
+ }
456
+
457
+ const dispatcher = new MyDispatcher()
458
+ dispatcher.serviceUnavailable({}, fakeServer)
459
+ })
460
+
461
+ test('LogController is exported from fastify', t => {
462
+ t.plan(2)
463
+ t.assert.ok(Fastify.LogController)
464
+ t.assert.strictEqual(Fastify.LogController, LogController)
465
+ })
466
+
145
467
  test('The serializer prevent fails if the request socket is undefined', t => {
146
468
  t.plan(1)
147
469
 
@@ -5,6 +5,7 @@ const http = require('node:http')
5
5
  const NotFound = require('http-errors').NotFound
6
6
  const Request = require('../../lib/request')
7
7
  const Reply = require('../../lib/reply')
8
+ const { LogController } = require('../../lib/log-controller')
8
9
  const Fastify = require('../..')
9
10
  const { Readable, Writable } = require('node:stream')
10
11
  const {
@@ -13,7 +14,8 @@ const {
13
14
  kReplySerializer,
14
15
  kReplyIsError,
15
16
  kReplySerializerDefault,
16
- kRouteContext
17
+ kRouteContext,
18
+ kLogController
17
19
  } = require('../../lib/symbols')
18
20
  const fs = require('node:fs')
19
21
  const path = require('node:path')
@@ -85,7 +87,14 @@ test('reply.send will logStream error and destroy the stream', t => {
85
87
  warn: () => { }
86
88
  }
87
89
 
88
- const reply = new Reply(response, { [kRouteContext]: { onSend: null } }, log)
90
+ const fakeRequest = {
91
+ [kRouteContext]: {
92
+ onSend: null,
93
+ server: { [kLogController]: new LogController() }
94
+ }
95
+ }
96
+
97
+ const reply = new Reply(response, fakeRequest, log)
89
98
  reply.send(payload)
90
99
  payload.destroy(new Error('stream error'))
91
100
 
@@ -764,7 +773,7 @@ test('non-string with custom json\'s content-type SHOULD be serialized as json',
764
773
 
765
774
  const result = await fetch(fastifyServer)
766
775
  t.assert.ok(result.ok)
767
- t.assert.strictEqual(result.headers.get('content-type'), 'application/json; version=2; charset=utf-8')
776
+ t.assert.strictEqual(result.headers.get('content-type'), 'application/json; version="2"; charset=utf-8')
768
777
  t.assert.deepStrictEqual(await result.text(), JSON.stringify({ key: 'hello world!' }))
769
778
  })
770
779
 
@@ -1149,7 +1158,7 @@ test('reply.hasHeader computes raw and fastify headers', async t => {
1149
1158
  })
1150
1159
 
1151
1160
  test('Reply should handle JSON content type with a charset', async t => {
1152
- t.plan(8)
1161
+ t.plan(10)
1153
1162
 
1154
1163
  const fastify = require('../../')()
1155
1164
 
@@ -1199,6 +1208,18 @@ test('Reply should handle JSON content type with a charset', async t => {
1199
1208
  .send({ hello: 'world' })
1200
1209
  })
1201
1210
 
1211
+ fastify.get('/upper-charset', function (req, reply) {
1212
+ reply
1213
+ .header('content-type', 'application/json; CHARSET=utf-8')
1214
+ .send({ hello: 'world' })
1215
+ })
1216
+
1217
+ fastify.get('/random-case', function (req, reply) {
1218
+ reply
1219
+ .header('content-type', 'ApPlIcAtIoN/JsOn; ChArSeT=utf-8')
1220
+ .send({ hello: 'world' })
1221
+ })
1222
+
1202
1223
  {
1203
1224
  const res = await fastify.inject('/default')
1204
1225
  t.assert.strictEqual(res.headers['content-type'], 'application/json; charset=utf-8')
@@ -1233,6 +1254,16 @@ test('Reply should handle JSON content type with a charset', async t => {
1233
1254
  t.assert.strictEqual(res.headers['content-type'], 'application/json; charset=utf-32')
1234
1255
  }
1235
1256
 
1257
+ {
1258
+ const res = await fastify.inject('/upper-charset')
1259
+ t.assert.strictEqual(res.headers['content-type'], 'application/json; CHARSET=utf-8')
1260
+ }
1261
+
1262
+ {
1263
+ const res = await fastify.inject('/random-case')
1264
+ t.assert.strictEqual(res.headers['content-type'], 'ApPlIcAtIoN/JsOn; ChArSeT=utf-8')
1265
+ }
1266
+
1236
1267
  {
1237
1268
  const res = await fastify.inject('/no-space-type-utf32')
1238
1269
  t.assert.strictEqual(res.headers['content-type'], 'application/json;charset=utf-32')
@@ -331,10 +331,10 @@ test('Request with trust proxy - no x-forwarded-host header', t => {
331
331
  })
332
332
 
333
333
  test('Request with trust proxy - no x-forwarded-host header and fallback to authority', t => {
334
- t.plan(2)
334
+ t.plan(3)
335
335
  const headers = {
336
336
  'x-forwarded-for': '2.2.2.2, 1.1.1.1',
337
- ':authority': 'authority'
337
+ ':authority': 'authority:4321'
338
338
  }
339
339
  const req = {
340
340
  method: 'GET',
@@ -370,15 +370,16 @@ test('Request with trust proxy - no x-forwarded-host header and fallback to auth
370
370
  const TpRequest = Request.buildRequest(Request, true)
371
371
  const request = new TpRequest('id', 'params', req, 'query', 'log', context)
372
372
  t.assert.ok(request instanceof TpRequest)
373
- t.assert.strictEqual(request.host, 'authority')
373
+ t.assert.strictEqual(request.host, 'authority:4321')
374
+ t.assert.strictEqual(request.port, 4321)
374
375
  })
375
376
 
376
377
  test('Request with trust proxy - x-forwarded-host header has precedence over host', t => {
377
- t.plan(2)
378
+ t.plan(4)
378
379
  const headers = {
379
380
  'x-forwarded-for': ' 2.2.2.2, 1.1.1.1',
380
- 'x-forwarded-host': 'fastify.test',
381
- host: 'hostname'
381
+ 'x-forwarded-host': 'fastify.test:1234',
382
+ host: 'hostname:5678'
382
383
  }
383
384
  const req = {
384
385
  method: 'GET',
@@ -390,7 +391,9 @@ test('Request with trust proxy - x-forwarded-host header has precedence over hos
390
391
  const TpRequest = Request.buildRequest(Request, true)
391
392
  const request = new TpRequest('id', 'params', req, 'query', 'log')
392
393
  t.assert.ok(request instanceof TpRequest)
393
- t.assert.strictEqual(request.host, 'fastify.test')
394
+ t.assert.strictEqual(request.host, 'fastify.test:1234')
395
+ t.assert.strictEqual(request.hostname, 'fastify.test')
396
+ t.assert.strictEqual(request.port, 1234)
394
397
  })
395
398
 
396
399
  test('Request with trust proxy - handles multiple entries in x-forwarded-host/proto', t => {
@@ -7,6 +7,7 @@ const split = require('split2')
7
7
  const pino = require('pino')
8
8
 
9
9
  const Fastify = require('../../fastify')
10
+ const { LogController } = require('../../lib/log-controller')
10
11
  const helper = require('../helper')
11
12
  const { once, on } = stream
12
13
  const { request } = require('./logger-test-utils')
@@ -16,7 +17,7 @@ t.test('logging', { timeout: 60000 }, async (t) => {
16
17
  let localhost
17
18
  let localhostForURL
18
19
 
19
- t.plan(15)
20
+ t.plan(16)
20
21
 
21
22
  t.before(async function () {
22
23
  [localhost, localhostForURL] = await helper.getLoopbackHost()
@@ -80,6 +81,44 @@ t.test('logging', { timeout: 60000 }, async (t) => {
80
81
  }
81
82
  })
82
83
 
84
+ await t.test('should not log if logController option disables logging', async (t) => {
85
+ const stream = split(JSON.parse)
86
+ const fastify = Fastify({
87
+ logger: {
88
+ stream,
89
+ level: 'info'
90
+ },
91
+ logController: new class extends LogController {
92
+ isLogDisabled () {
93
+ t.assert.ok(true, 'isLogDisabled should be called')
94
+ return true // disable logging to test that incomingRequest is not called
95
+ }
96
+ }()
97
+ })
98
+ t.after(() => fastify.close())
99
+
100
+ fastify.get('/info', function (req, reply) {
101
+ reply.send({ hello: 'world' })
102
+ })
103
+
104
+ await fastify.ready()
105
+ const server = await fastify.listen({ port: 0, host: localhost })
106
+ const lines = [
107
+ { msg: `Server listening at ${server}` }
108
+ ]
109
+ // 2:
110
+ // - incoming request
111
+ // - request completed
112
+ t.plan(lines.length + 2)
113
+
114
+ await request(`http://${localhostForURL}:` + fastify.server.address().port + '/info')
115
+
116
+ for await (const [line] of on(stream, 'data')) {
117
+ t.assert.ok(partialDeepStrictEqual(line, lines.shift()))
118
+ if (lines.length === 0) break
119
+ }
120
+ })
121
+
83
122
  await t.test('should log the error if no error handler is defined', async (t) => {
84
123
  const stream = split(JSON.parse)
85
124
  const fastify = Fastify({
@@ -6,7 +6,7 @@ const JSONStream = require('JSONStream')
6
6
  const Readable = require('node:stream').Readable
7
7
  const split = require('split2')
8
8
  const Fastify = require('..')
9
- const { kDisableRequestLogging } = require('../lib/symbols.js')
9
+ const { kLogController } = require('../lib/symbols.js')
10
10
 
11
11
  test('Destroying streams prematurely should call abort method', (t, testDone) => {
12
12
  t.plan(7)
@@ -87,7 +87,7 @@ test('Destroying streams prematurely, log is disabled', (t, testDone) => {
87
87
  const http = require('node:http')
88
88
 
89
89
  fastify.get('/', function (request, reply) {
90
- reply.log[kDisableRequestLogging] = true
90
+ reply.server[kLogController].disableRequestLogging = true
91
91
 
92
92
  let sent = false
93
93
  const reallyLongStream = new stream.Readable({