Skip to content

Commit

Permalink
Fix memory from leaking
Browse files Browse the repository at this point in the history
  • Loading branch information
NV4RE committed Aug 26, 2020
1 parent a8fd6b1 commit 87da2de
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ const retryBulkCreate = async (
};

export const executor = async () => {
try {
const events: IAllEventWithId[] = await poll(consumerEventClient, 200);
if (events.length) {
await retryBulkCreate(events, Number.MAX_VALUE, 10000);
console.log(`Inserted ${events.length} rows`);
consumerEventClient.commit();
while (true) {
try {
const events: IAllEventWithId[] = await poll(consumerEventClient, 200);
if (events.length) {
await retryBulkCreate(events, Number.MAX_VALUE, 10000);
console.log(`Inserted ${events.length} rows`);
consumerEventClient.commit();
}
} catch (error) {
// Handle error here
console.warn(error);
await sleep(1000);
}
} catch (error) {
// Handle error here
console.warn(error);
await sleep(1000);
} finally {
setImmediate(executor);
}
};

0 comments on commit 87da2de

Please sign in to comment.