MCPcopy
hub / github.com/nodejs/undici / errorAndChunkedEncodingPipelining

Function errorAndChunkedEncodingPipelining

test/node-test/client-errors.js:238–285  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

236errorAndPipelining(consts.ASYNC_ITERATOR)
237
238function errorAndChunkedEncodingPipelining (type) {
239 test(`POST with chunked encoding, ${type} body that errors and pipelining 1 should reconnect`, async (t) => {
240 const trackPostWithPlan = type !== consts.STREAM
241 const p = tspl(t, { plan: trackPostWithPlan ? 12 : 8 })
242
243 const server = createServer({ joinDuplicateHeaders: true })
244 installErrorAndReconnectServer(server, p, {
245 contentLength: undefined,
246 trackPostWithPlan
247 })
248 t.after(closeServerAsPromise(server))
249
250 server.listen(0, () => {
251 const client = new Client(`http://localhost:${server.address().port}`)
252 t.after(client.destroy.bind(client))
253
254 client.request({
255 path: '/',
256 method: 'POST',
257 opaque: 'asd',
258 body: maybeWrapStream(new Readable({
259 read () {
260 this.push('a string')
261 this.destroy(new Error('kaboom'))
262 }
263 }), type)
264 }, (err, data) => {
265 p.strictEqual(err.message, 'kaboom')
266 p.strictEqual(data.opaque, 'asd')
267 })
268
269 // this will be queued up
270 client.request({ path: '/', method: 'GET' }, (err, { statusCode, headers, body }) => {
271 p.ifError(err)
272 p.strictEqual(statusCode, 200)
273 p.strictEqual(headers['content-type'], 'text/plain')
274 const bufs = []
275 body.on('data', (buf) => {
276 bufs.push(buf)
277 })
278 body.on('end', () => {
279 p.strictEqual('hello', Buffer.concat(bufs).toString('utf8'))
280 })
281 })
282 })
283 await p.completed
284 })
285}
286
287errorAndChunkedEncodingPipelining(consts.STREAM)
288errorAndChunkedEncodingPipelining(consts.ASYNC_ITERATOR)

Callers 1

client-errors.jsFile · 0.85

Calls 9

createServerFunction · 0.85
closeServerAsPromiseFunction · 0.85
maybeWrapStreamFunction · 0.85
listenMethod · 0.80
requestMethod · 0.45
onMethod · 0.45
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…