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

[Service Bus] Receivers not closed correctly when client is closed #17932

Closed
pewe01 opened this issue Sep 29, 2021 · 3 comments
Closed

[Service Bus] Receivers not closed correctly when client is closed #17932

pewe01 opened this issue Sep 29, 2021 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@pewe01
Copy link

pewe01 commented Sep 29, 2021

  • Package Name: service-bus
  • Package Version: 7.3.0

Bug Description

ServiceBusReceivers seem not to be closed as expected when the ServiceBusClient is closed. The problem occurs when there are at least two receivers created and subscribed on.

To Reproduce

it('should close all receivers of the connection context and shut down gracefully when serviceBusClient.close() was called', async () => {
        // Given
        const serviceBusClient = new ServiceBusClient(${serviceBusConnectionString});
        const receiver1 = serviceBusClient.createReceiver(${topic1});
        const receiver2 = serviceBusClient.createReceiver(${topic2});

        receiver1.subscribe({
            processMessage: async () => {},
            processError: async () => {}
        });
        receiver2.subscribe({
            processMessage: async () => {},
            processError: async () => {}
        });

        // When
        await serviceBusClient.close();

        const messageReceiverList = Object.keys(serviceBusClient["_connectionContext"]["messageReceivers"])

        // Then
        expect(serviceBusClient["_connectionContext"]["wasConnectionCloseCalled"]).toBeTruthy();
        expect(Object.keys(serviceBusClient["_connectionContext"]["messageReceivers"]).length).toEqual(2);
        expect(serviceBusClient["_connectionContext"]["messageReceivers"][messageReceiverList[0]]["baseName"]).toEqual(${topic1});
        expect(serviceBusClient["_connectionContext"]["messageReceivers"][messageReceiverList[0]]["_wasClosedPermanently"]).toBeTruthy();
        expect(serviceBusClient["_connectionContext"]["messageReceivers"][messageReceiverList[1]]["baseName"]).toEqual(${topic2});
        expect(serviceBusClient["_connectionContext"]["messageReceivers"][messageReceiverList[1]]["_wasClosedPermanently"]).toBeTruthy();
});

Expected behavior

  1. The test shown above should succeed. After closing the service bus client the connection context should contain two message receivers both with _wasClosedPermanently flag set to true.
  2. Jest should exit after test execution.

Actual behavior

  1. After closing the service bus client the connection context only contains one receiver.
  2. Jest does not exit. The following warning is shown:
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Additional context

This problem occurs since SDK version 7.1.0. With version 7.0.5 the test shown above succeeds and Jest exits.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 29, 2021
@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Service Bus labels Sep 29, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 29, 2021
@jeremymeng jeremymeng assigned jeremymeng and unassigned chradek Oct 15, 2021
@jeremymeng
Copy link
Member

@pewe01 Thanks for the report! I am taking a look.

After closing the service bus client the connection context should contain two message receivers

I would expect that the number of receivers to be zero after calling close() on the client as we remove receivers from context when the link is closed.

@jeremymeng
Copy link
Member

jeremymeng commented Oct 26, 2021

The different behavior started appear after PR #15098

@jeremymeng
Copy link
Member

@pewe01 the fix should be in the latest version (7.4.0) now. Let us know if you are seeing other issues.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

4 participants