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

Function setStreamTimeout

lib/internal/stream_base_commons.js:236–265  ·  view source on GitHub ↗
(msecs, callback)

Source from the content-addressed store, hash-verified

234}
235
236function setStreamTimeout(msecs, callback) {
237 if (this.destroyed)
238 return this;
239
240 this.timeout = msecs;
241
242 // Type checking identical to timers.enroll()
243 msecs = getTimerDuration(msecs, 'msecs');
244
245 // Attempt to clear an existing timer in both cases -
246 // even if it will be rescheduled we don't want to leak an existing timer.
247 clearTimeout(this[kTimeout]);
248
249 if (msecs === 0) {
250 if (callback !== undefined) {
251 validateFunction(callback, 'callback');
252 this.removeListener('timeout', callback);
253 }
254 } else {
255 this[kTimeout] = setUnrefTimeout(this._onTimeout.bind(this), msecs);
256 if (this[kSession]) this[kSession][kUpdateTimer]();
257 if (this[kBoundSession]) this[kBoundSession][kUpdateTimer]();
258
259 if (callback !== undefined) {
260 validateFunction(callback, 'callback');
261 this.once('timeout', callback);
262 }
263 }
264 return this;
265}
266
267module.exports = {
268 writevGeneric,

Callers

nothing calls this directly

Calls 6

getTimerDurationFunction · 0.85
setUnrefTimeoutFunction · 0.85
clearTimeoutFunction · 0.50
removeListenerMethod · 0.45
bindMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…