MCPcopy Index your code
hub / github.com/nodejs/node / [kWriteGeneric]

Method [kWriteGeneric]

lib/internal/http2/core.js:2262–2342  ·  view source on GitHub ↗
(writev, data, encoding, cb)

Source from the content-addressed store, hash-verified

2260 }
2261
2262 [kWriteGeneric](writev, data, encoding, cb) {
2263 // When the Http2Stream is first created, it is corked until the
2264 // handle and the stream ID is assigned. However, if the user calls
2265 // uncork() before that happens, the Duplex will attempt to pass
2266 // writes through. Those need to be queued up here.
2267 if (this.pending) {
2268 this.once(
2269 'ready',
2270 this[kWriteGeneric].bind(this, writev, data, encoding, cb),
2271 );
2272 return;
2273 }
2274
2275 // If the stream has been destroyed, there's nothing else we can do
2276 // because the handle has been destroyed. This should only be an
2277 // issue if a write occurs before the 'ready' event in the case where
2278 // the duplex is uncorked before the stream is ready to go. In that
2279 // case, drop the data on the floor. An error should have already been
2280 // emitted.
2281 if (this.destroyed)
2282 return;
2283
2284 this[kUpdateTimer]();
2285 if (!this.headersSent)
2286 this[kProceed]();
2287
2288 let req;
2289
2290 let waitingForWriteCallback = true;
2291 let waitingForEndCheck = true;
2292 let writeCallbackErr;
2293 let endCheckCallbackErr;
2294 const done = () => {
2295 if (waitingForEndCheck || waitingForWriteCallback) return;
2296 const err = aggregateTwoErrors(endCheckCallbackErr, writeCallbackErr);
2297 // writeGeneric does not destroy on error and
2298 // we cannot enable autoDestroy,
2299 // so make sure to destroy on error.
2300 if (err) {
2301 this.destroy(err);
2302 }
2303 cb(err);
2304 };
2305 const writeCallback = (err) => {
2306 waitingForWriteCallback = false;
2307 writeCallbackErr = err;
2308 done();
2309 };
2310 const endCheckCallback = (err) => {
2311 waitingForEndCheck = false;
2312 endCheckCallbackErr = err;
2313 done();
2314 };
2315 // Shutdown write stream right after last chunk is sent
2316 // so final DATA frame can include END_STREAM flag
2317 process.nextTick(() => {
2318 if (writeCallbackErr ||
2319 !this._writableState.ending ||

Callers

nothing calls this directly

Calls 8

debugStreamObjFunction · 0.85
writevGenericFunction · 0.85
writeGenericFunction · 0.85
trackWriteStateFunction · 0.85
onceMethod · 0.45
bindMethod · 0.45
callMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected