Skip to content

Commit

Permalink
Merge pull request #8 from maticnetwork/enhancement/not-required-empt…
Browse files Browse the repository at this point in the history
…y-arrow-function-removed

Empty arrow function removed
  • Loading branch information
nivida authored Aug 28, 2023
2 parents c7eeaa5 + 3485316 commit 198d933
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/kafka/producer/synchronous_producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export class SynchronousProducer extends AbstractProducer {
timestamp?: number
): Promise<DeliveryReport | KafkaError> {
return new Promise(async (resolve, reject) => {
let deliveryListener: (error: LibrdKafkaError, report: DeliveryReport) => void = () => { };
// @ts-ignore
let deliveryListener: (error: LibrdKafkaError, report: DeliveryReport) => void;

try {
const identifier = { time: Date.now() };
const timer = setTimeout(() => {
Expand Down Expand Up @@ -88,7 +90,9 @@ export class SynchronousProducer extends AbstractProducer {
return;
}
};

this.on("delivery-report", deliveryListener);

await this.sendToInternalProducer(
key,
message,
Expand All @@ -102,7 +106,10 @@ export class SynchronousProducer extends AbstractProducer {
this.poll();
}, 100);
} catch (error) {
this.removeListener("delivery-report", deliveryListener);
// @ts-ignore
if (deliveryListener) {
this.removeListener("delivery-report", deliveryListener);
}

throw KafkaError.createUnknown(error);
}
Expand Down

0 comments on commit 198d933

Please sign in to comment.