MCPcopy Index your code
hub / github.com/nodejs/undici / socketFailEndWrite

Function socketFailEndWrite

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

Source from the content-addressed store, hash-verified

1005socketFailWrite(consts.ASYNC_ITERATOR)
1006
1007function socketFailEndWrite (type) {
1008 test(`socket fail while ending ${type} request body`, async (t) => {
1009 const p = tspl(t, { plan: 3 })
1010
1011 const server = createServer({ joinDuplicateHeaders: true })
1012 server.once('request', (req, res) => {
1013 res.end()
1014 })
1015 t.after(closeServerAsPromise(server))
1016
1017 server.listen(0, () => {
1018 const client = new Client(`http://localhost:${server.address().port}`, {
1019 pipelining: 2
1020 })
1021 t.after(client.destroy.bind(client))
1022
1023 const _err = new Error('kaboom')
1024 client.on('connect', () => {
1025 process.nextTick(() => {
1026 client[kSocket].destroy(_err)
1027 })
1028 })
1029 const preBody = new Readable({ read () {} })
1030 preBody.push(null)
1031 const body = maybeWrapStream(preBody, type)
1032
1033 client.request({
1034 path: '/',
1035 method: 'POST',
1036 body
1037 }, (err) => {
1038 p.strictEqual(err, _err)
1039 })
1040 client.close((err) => {
1041 p.ifError(err)
1042 client.close((err) => {
1043 p.ok(err instanceof errors.ClientDestroyedError)
1044 })
1045 })
1046 })
1047
1048 await p.completed
1049 })
1050}
1051
1052socketFailEndWrite(consts.STREAM)
1053socketFailEndWrite(consts.ASYNC_ITERATOR)

Callers 1

client-errors.jsFile · 0.85

Calls 11

createServerFunction · 0.85
closeServerAsPromiseFunction · 0.85
maybeWrapStreamFunction · 0.85
listenMethod · 0.80
okMethod · 0.80
closeMethod · 0.65
endMethod · 0.45
onMethod · 0.45
destroyMethod · 0.45
pushMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…