(type)
| 179 | } |
| 180 | |
| 181 | function errorAndPipelining (type) { |
| 182 | test(`POST with a ${type} that errors and pipelining 1 should reconnect`, async (t) => { |
| 183 | const trackPostWithPlan = type !== consts.STREAM |
| 184 | const p = tspl(t, { plan: trackPostWithPlan ? 12 : 8 }) |
| 185 | |
| 186 | const server = createServer({ joinDuplicateHeaders: true }) |
| 187 | installErrorAndReconnectServer(server, p, { |
| 188 | contentLength: '42', |
| 189 | trackPostWithPlan |
| 190 | }) |
| 191 | t.after(closeServerAsPromise(server)) |
| 192 | |
| 193 | server.listen(0, () => { |
| 194 | const client = new Client(`http://localhost:${server.address().port}`) |
| 195 | t.after(client.destroy.bind(client)) |
| 196 | |
| 197 | client.request({ |
| 198 | path: '/', |
| 199 | method: 'POST', |
| 200 | headers: { |
| 201 | // higher than the length of the string |
| 202 | 'content-length': 42 |
| 203 | }, |
| 204 | opaque: 'asd', |
| 205 | body: maybeWrapStream(new Readable({ |
| 206 | read () { |
| 207 | this.push('a string') |
| 208 | this.destroy(new Error('kaboom')) |
| 209 | } |
| 210 | }), type) |
| 211 | }, (err, data) => { |
| 212 | p.strictEqual(err.message, 'kaboom') |
| 213 | p.strictEqual(data.opaque, 'asd') |
| 214 | }) |
| 215 | |
| 216 | // this will be queued up |
| 217 | client.request({ path: '/', method: 'GET', idempotent: false }, (err, { statusCode, headers, body }) => { |
| 218 | p.ifError(err) |
| 219 | p.strictEqual(statusCode, 200) |
| 220 | p.strictEqual(headers['content-type'], 'text/plain') |
| 221 | const bufs = [] |
| 222 | body.on('data', (buf) => { |
| 223 | bufs.push(buf) |
| 224 | }) |
| 225 | body.on('end', () => { |
| 226 | p.strictEqual('hello', Buffer.concat(bufs).toString('utf8')) |
| 227 | }) |
| 228 | }) |
| 229 | }) |
| 230 | |
| 231 | await p.completed |
| 232 | }) |
| 233 | } |
| 234 | |
| 235 | errorAndPipelining(consts.STREAM) |
| 236 | errorAndPipelining(consts.ASYNC_ITERATOR) |
no test coverage detected
searching dependent graphs…