fastify 3.27.3 → 3.27.4
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.
- package/fastify.js +1 -1
- package/package.json +1 -1
- package/test/internals/reply.test.js +13 -14
package/fastify.js
CHANGED
package/package.json
CHANGED
|
@@ -5,9 +5,8 @@ const test = t.test
|
|
|
5
5
|
const sget = require('simple-get').concat
|
|
6
6
|
const http = require('http')
|
|
7
7
|
const NotFound = require('http-errors').NotFound
|
|
8
|
-
const EventEmitter = require('events').EventEmitter
|
|
9
8
|
const Reply = require('../../lib/reply')
|
|
10
|
-
const { Writable } = require('stream')
|
|
9
|
+
const { Readable, Writable } = require('stream')
|
|
11
10
|
const {
|
|
12
11
|
kReplyErrorHandlerCalled,
|
|
13
12
|
kReplyHeaders,
|
|
@@ -40,30 +39,30 @@ test('Once called, Reply should return an object with methods', t => {
|
|
|
40
39
|
test('reply.send will logStream error and destroy the stream', { only: true }, t => {
|
|
41
40
|
t.plan(1)
|
|
42
41
|
let destroyCalled
|
|
43
|
-
const payload = new
|
|
42
|
+
const payload = new Readable({
|
|
43
|
+
read () {},
|
|
44
|
+
destroy (err, cb) {
|
|
45
|
+
destroyCalled = true
|
|
46
|
+
cb(err)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
44
49
|
|
|
45
|
-
const response =
|
|
50
|
+
const response = new Writable()
|
|
51
|
+
Object.assign(response, {
|
|
46
52
|
setHeader: () => {},
|
|
47
53
|
hasHeader: () => false,
|
|
48
54
|
getHeader: () => undefined,
|
|
49
55
|
writeHead: () => {},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
destroy: () => (destroyCalled = true),
|
|
53
|
-
on: () => {}
|
|
54
|
-
}
|
|
56
|
+
headersSent: true
|
|
57
|
+
})
|
|
55
58
|
|
|
56
59
|
const log = {
|
|
57
60
|
warn: () => {}
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
Object.assign(payload, {
|
|
61
|
-
pipe: () => {},
|
|
62
|
-
destroy: () => {}
|
|
63
|
-
})
|
|
64
63
|
const reply = new Reply(response, { context: { onSend: null } }, log)
|
|
65
64
|
reply.send(payload)
|
|
66
|
-
payload.
|
|
65
|
+
payload.destroy(new Error('stream error'))
|
|
67
66
|
|
|
68
67
|
t.equal(destroyCalled, true, 'Error not logged and not streamed')
|
|
69
68
|
})
|