azure-sdk-for-js: [Service Bus] Attempt to settle msg after session lock expiry yields unhelpful error messages

In a session enabled queue, completing message right after session lock expiry results in the error This message has been already settled. from https://github.com/Azure/azure-sdk-for-js/blob/0f05661cced8b0ed9cd036b7a13030499d185aa1/packages/%40azure/servicebus/data-plane/lib/serviceBusMessage.ts#L891

Where as completing the message after a little while of the session lock expiry results in the error ``Cannot find the receiver with name …` from https://github.com/Azure/azure-sdk-for-js/blob/0f05661cced8b0ed9cd036b7a13030499d185aa1/packages/%40azure/servicebus/data-plane/lib/serviceBusMessage.ts#L895

Neither is very helpful to the user.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

That’s right, the user’s onError handler would be invoked in such cases and that needs to be understood by the user maybe. Unlike, say, regular promise’s reject, resolve callbacks, our callbacks are not mutually exclusive. That may need to change or perhaps just documented? Yes, whenever there’s an error the onError handler gets invoked one way or the other. If onMessage throws error only then would onMessage stop executing.

Update - with https://github.com/Azure/azure-sdk-for-js/pull/1128:

  • Updated session lock renewal tests
  • Testing done:
    • All the tests pass, including lock related ones (glad to see this! they took 1hr 18 min to complete)

Pending items:

These errors are thrown by the SDK even before the message settle request is made to Service Bus.

We need to understand 2 things here

  • Understand how the remote_settled property got set to true
  • Understand how the there is no more receiver

One possible fix is to check the sessionLockedUntilUtc before either of these errors are thrown. If current time is greater than sessionLockedUntilUtc, then we can throw a better error message.