mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Simply GuardedStream check
This commit is contained in:
parent
ce1f4300ff
commit
c05933f652
@ -36,9 +36,8 @@ export function isGuarded<T extends NodeJS.EventEmitter>(stream: T): stream is G
|
|||||||
*/
|
*/
|
||||||
function guardingErrorListener(this: Guarded, error: Error): void {
|
function guardingErrorListener(this: Guarded, error: Error): void {
|
||||||
// Only fall back to this if no new listeners are attached since guarding started.
|
// Only fall back to this if no new listeners are attached since guarding started.
|
||||||
// Not storing the index when guarding starts since listeners could be removed.
|
const errorListeners = this.listeners('error');
|
||||||
const idx = this.listeners('error').indexOf(guardingErrorListener);
|
if (errorListeners[errorListeners.length - 1] === guardingErrorListener) {
|
||||||
if (idx === this.listenerCount('error') - 1) {
|
|
||||||
this[guardedErrors].push(error);
|
this[guardedErrors].push(error);
|
||||||
if (!this[guardedTimeout]) {
|
if (!this[guardedTimeout]) {
|
||||||
this[guardedTimeout] = setTimeout((): void => {
|
this[guardedTimeout] = setTimeout((): void => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user