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 an issue where links are kept alive #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.0.3 - (2024-06-12)

- Release the resources if `Session.createReceiver()` rejects due to timeout.

### 3.0.2 - (2024-05-02)

- Set the max listener limit to 1000 for `RheaConnection`
Expand Down
11 changes: 10 additions & 1 deletion lib/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License. See License in the project root for license information.

import * as log from "./log";
import { Connection } from "./connection";
import { Connection, CreateReceiverOptions } from "./connection";
import { Receiver, ReceiverOptions } from "./receiver";
import { Sender, SenderOptions } from "./sender";
import {
Expand Down Expand Up @@ -396,6 +396,15 @@ export class Session extends Entity {
const msg: string = `Unable to create the amqp receiver '${receiver.name}' on amqp ` +
`session '${this.id}' due to operation timeout.`;
log.error("[%s] %s", this.connection.id, msg);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are reject cases above too but I'd like to limit the scope of this PR to just timeout for now.

const createReceiverOptions = options as CreateReceiverOptions;
if (createReceiverOptions?.session?.createReceiver) {
// being called on a session passed via the options so don't close the session
receiver.close({ closeSession: false }).then(() => { receiver.remove(); })
} else {
receiver.close({ closeSession: true }).then(() => { receiver.remove(); })
}
Comment on lines +400 to +406
Copy link
Collaborator

@HarshaNalluru HarshaNalluru Jun 11, 2024

Choose a reason for hiding this comment

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

[NIT]

Should this just be abstracted into a receiverCleanup method so that it can be reused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! But could wait until it is going to be re-used.


return reject(new OperationTimeoutError(msg));
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rhea-promise",
"version": "3.0.2",
"version": "3.0.3",
"description": "A Promisified layer over rhea AMQP client",
"license": "Apache-2.0",
"main": "./dist/lib/index.js",
Expand Down
Loading