MCPcopy
hub / github.com/webpack/webpack / _handleResult

Method _handleResult

lib/util/AsyncQueue.js:389–429  ·  view source on GitHub ↗

* Processes the provided entry. * @param {AsyncQueueEntry<T, K, R>} entry the entry * @param {(WebpackError | null)=} err error, if any * @param {(R | null)=} result result, if any * @returns {void}

(entry, err, result)

Source from the content-addressed store, hash-verified

387 * @returns {void}
388 */
389 _handleResult(entry, err, result) {
390 this.hooks.result.callAsync(entry.item, err, result, (hookError) => {
391 const error = hookError
392 ? makeWebpackError(hookError, `AsyncQueue(${this._name}).hooks.result`)
393 : err;
394
395 const callback = /** @type {Callback<R>} */ (entry.callback);
396 const callbacks = entry.callbacks;
397 entry.state = DONE_STATE;
398 entry.callback = undefined;
399 entry.callbacks = undefined;
400 entry.result = result;
401 entry.error = error;
402
403 const root = this._root;
404 root._activeTasks--;
405 if (root._willEnsureProcessing === false && root._needProcessing) {
406 root._willEnsureProcessing = true;
407 setImmediate(root._ensureProcessing);
408 }
409
410 if (inHandleResult++ > 3) {
411 process.nextTick(() => {
412 callback(error, result);
413 if (callbacks !== undefined) {
414 for (const callback of callbacks) {
415 callback(error, result);
416 }
417 }
418 });
419 } else {
420 callback(error, result);
421 if (callbacks !== undefined) {
422 for (const callback of callbacks) {
423 callback(error, result);
424 }
425 }
426 }
427 inHandleResult--;
428 });
429 }
430
431 clear() {
432 this._entries.clear();

Callers 3

addMethod · 0.95
stopMethod · 0.95
_startProcessingMethod · 0.95

Calls 2

makeWebpackErrorFunction · 0.85
callbackFunction · 0.50

Tested by

no test coverage detected