Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Consumer Memory Leak: Hanging promises #80

Merged
merged 4 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pulsar-flex",
"version": "1.0.1-beta.8",
"version": "1.0.1-beta.9",
"description": "A package that natively supports pulsar api",
"main": "src/index.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions src/consumer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ module.exports = class Consumer {
this._receiveQueue.isEmpty() ||
(this._isRedeliveringUnacknowledgedMessages && this._prioritizeUnacknowledgedMessages)
) {
this._processTimeoutInterval = setTimeout(async () => {
await process();
}, 1000);
this._processTimeoutInterval = setTimeout(process, 1000);
return;
}
const message = this._receiveQueue.dequeue();
Expand All @@ -319,7 +317,8 @@ module.exports = class Consumer {
ackType: options.type ? options.type : ACK_TYPES.INDIVIDUAL,
}),
});
await process();
process();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add catch/then with logs in trace level and warn level.

Because currently we cant really tell what happened to this promise.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, nice catch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done now.

return;
};
await this._flow(this._receiveQueueSize);
await process();
Expand Down