diff --git a/src/bot.ts b/src/bot.ts index 148eb1e5fb1103d17bfe042a65390cd8aace6944..9f51930b833c85c95f4b1231036073c492d59a9d 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -150,7 +150,8 @@ export class WorkerBee extends EventEmitter implements IWorkerBee { } // Else -> no new block } catch (error) { // Ensure we are emitting the Error instance - super.emit("error", new WorkerBeeError(`Error occurred during automation: ${String(error)}`, error)); + if (super.listenerCount("error") > 0) + super.emit("error", new WorkerBeeError(`Error occurred during automation: ${String(error)}`, error)); // Wait before any next operation is performed to reduce spamming the API await new Promise(res => { setTimeout(res, DEFAULT_BLOCK_INTERVAL_TIMEOUT); }); diff --git a/src/interfaces.ts b/src/interfaces.ts index 82c5e9f2a8b15eaed88f08c5159d37c0b356e5e6..cb30acd0b1086aa3288d7a425c5fa89063365346 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -149,6 +149,8 @@ export interface IWorkerBeeConstructor { * Constructs new WorkerBee bot object * * @param configuration Configuration for the automation + * + * @note If you do not register an "error" event listener, the error will be dropped silently */ new(configuration?: Partial<IStartConfiguration>): IWorkerBee; }