feat: switch to `EventEmitterAsyncRessource` type for `@types/node`
[poolifier.git] / src / pools / abstract-pool.ts
index c56beaa6d801843c043f091963cea385b72eccee..f1d8b058ca414c136f71fc92be19ba7d352e7664 100644 (file)
@@ -1,7 +1,7 @@
 import { randomUUID } from 'node:crypto'
 import { performance } from 'node:perf_hooks'
 import type { TransferListItem } from 'node:worker_threads'
-import { type EventEmitter, EventEmitterAsyncResource } from 'node:events'
+import { EventEmitterAsyncResource } from 'node:events'
 import type {
   MessageValue,
   PromiseResponseWrapper,
@@ -70,7 +70,7 @@ export abstract class AbstractPool<
   public readonly workerNodes: Array<IWorkerNode<Worker, Data>> = []
 
   /** @inheritDoc */
-  public emitter?: EventEmitter | EventEmitterAsyncResource
+  public emitter?: EventEmitterAsyncResource
 
   /**
    * The task execution response promise map:
@@ -944,9 +944,7 @@ export abstract class AbstractPool<
       })
     )
     this.emitter?.emit(PoolEvents.destroy, this.info)
-    if (this.emitter instanceof EventEmitterAsyncResource) {
-      this.emitter?.emitDestroy()
-    }
+    this.emitter?.emitDestroy()
     this.started = false
   }