(fn, position = -1, context = kEmptyObject, thisArg, ...args)
| 590 | } |
| 591 | |
| 592 | traceCallback(fn, position = -1, context = kEmptyObject, thisArg, ...args) { |
| 593 | if (!this.hasSubscribers) { |
| 594 | return ReflectApply(fn, thisArg, args); |
| 595 | } |
| 596 | |
| 597 | const { error } = this; |
| 598 | const continuationWindow = this.#continuationWindow; |
| 599 | |
| 600 | function wrappedCallback(err, res) { |
| 601 | if (err) { |
| 602 | context.error = err; |
| 603 | error.publish(context); |
| 604 | } else { |
| 605 | context.result = res; |
| 606 | } |
| 607 | |
| 608 | // Use continuation window for asyncStart/asyncEnd around callback |
| 609 | // eslint-disable-next-line no-unused-vars |
| 610 | using scope = continuationWindow.withScope(context); |
| 611 | return ReflectApply(callback, this, arguments); |
| 612 | } |
| 613 | |
| 614 | const callback = ArrayPrototypeAt(args, position); |
| 615 | validateFunction(callback, 'callback'); |
| 616 | ArrayPrototypeSplice(args, position, 1, wrappedCallback); |
| 617 | |
| 618 | // eslint-disable-next-line no-unused-vars |
| 619 | using scope = this.#callWindow.withScope(context); |
| 620 | try { |
| 621 | return ReflectApply(fn, thisArg, args); |
| 622 | } catch (err) { |
| 623 | context.error = err; |
| 624 | error.publish(context); |
| 625 | throw err; |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | function tracingChannel(nameOrChannels) { |
no test coverage detected