MCPcopy Index your code
hub / github.com/nodejs/node / writeIterable

Function writeIterable

deps/undici/undici.js:8104–8140  ·  view source on GitHub ↗
(abort, body, client, request, socket, contentLength, header, expectsPayload)

Source from the content-addressed store, hash-verified

8102 }
8103 __name(writeBlob, "writeBlob");
8104 async function writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload) {
8105 assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
8106 let callback = null;
8107 function onDrain() {
8108 if (callback) {
8109 const cb = callback;
8110 callback = null;
8111 cb();
8112 }
8113 }
8114 __name(onDrain, "onDrain");
8115 const waitForDrain = /* @__PURE__ */ __name(() => new Promise((resolve, reject) => {
8116 assert(callback === null);
8117 if (socket[kError]) {
8118 reject(socket[kError]);
8119 } else {
8120 callback = resolve;
8121 }
8122 }), "waitForDrain");
8123 socket.on("close", onDrain).on("drain", onDrain);
8124 const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header });
8125 try {
8126 for await (const chunk of body) {
8127 if (socket[kError]) {
8128 throw socket[kError];
8129 }
8130 if (!writer.write(chunk)) {
8131 await waitForDrain();
8132 }
8133 }
8134 writer.end();
8135 } catch (err) {
8136 writer.destroy(err);
8137 } finally {
8138 socket.off("close", onDrain).off("drain", onDrain);
8139 }
8140 }
8141 __name(writeIterable, "writeIterable");
8142 var AsyncWriter = class {
8143 static {

Callers 2

writeH1Function · 0.70
writeBodyH2Function · 0.70

Calls 14

writeMethod · 0.95
endMethod · 0.95
destroyMethod · 0.95
__nameFunction · 0.85
abortFunction · 0.70
onBodySentMethod · 0.65
onRequestSentMethod · 0.65
assertFunction · 0.50
rejectFunction · 0.50
waitForDrainFunction · 0.50
onMethod · 0.45
offMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…