Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.09k stars 1.2k forks source link

Exception: The response link '{some-uuid}' was not found in the entity management node $management. #25258

Open AndyM1H opened 1 year ago

AndyM1H commented 1 year ago

Describe the bug When I try to schedule a message to the service bus queue from my timer trigger function using the .scheduleMessages() method, I encounter an exception. This exception is only encountered on versions of the package that are greater than v7.8.0. or equal.

Exception's stack

 System.Private.CoreLib: Exception while executing function: Functions.functionName. System.Private.CoreLib: Result: Failure
 Exception: The response link '28fed9fd-4c9a-b74a-b7b8-4612933b8225' was not found in the entity management node $management.
 Stack: ServiceBusError: The response link '28fed9fd-4c9a-b74a-b7b8-4612933b8225' was not found in the entity management node $management.
     at translateServiceBusError (/home/andrei/dev/Work/work-project/node_modules/.pnpm/@azure+service-bus@7.8.0/node_modules/@azure/service-bus/dist/index.js:4381:16)
     at ManagementClient._makeManagementRequest (/home/andrei/dev/Work/work-project/node_modules/.pnpm/@azure+service-bus@7.8.0/node_modules/@azure/service-bus/dist/index.js:5035:37)
     at processTicksAndRejections (internal/process/task_queues.js:95:5)
     at async ManagementClient.scheduleMessages (/home/andrei/dev/Work/work-project/node_modules/.pnpm/@azure+service-bus@7.8.0/node_modules/@azure/service-bus/dist/index.js:5271:28)
     at async Object.retry (/home/andrei/dev/Work/work-project/node_modules/.pnpm/@azure+core-amqp@3.2.2/node_modules/@azure/core-amqp/dist/index.js:1443:22)
     at async Promise.all (index 0)
     at async handler (/home/andrei/dev/Work/work-project/src/services/timer/handlers/the-function.js:37:7).

To Reproduce Steps to reproduce the behavior:

  1. Create an instance of the Service Bus Client.
  2. Create a ServiceBusSender instance using the Service Bus Client.
  3. Invoke the scheduleMessages() function.

Expected behavior Messages are successfully scheduled to the service bus queue.

jeremymeng commented 1 year ago

@AndyM1H thank you for reporting the issue! This must be related to this change: https://github.com/Azure/azure-sdk-for-js/pull/24509. After the PR, when we need to open a new link, a new replyTo guid is generated.

Does the issue happen every time you call scheduleMessages()? Could you please share you code snippets that reproduced the problem?

AndyM1H commented 1 year ago

@jeremymeng I have an update for you. Messages were scheduled as expected, but there is the exception in the timer trigger after that messages were scheduled. So, Service Bus Queue receives scheduled messages at the time.

Code snippet

await Promise.all(
    users
      .map((user) => 
        ({
          body: {
            userId: user.id,
          },
        })
      )
      .map((message, index) =>
        sender.scheduleMessages(
          message,
          new Date(
            syncStartTimestamp +
              index * syncPeriod +
              OFFSET_IN_MILLISECONDS
          )
        )
      )
  );

If we add catch statement to scheduleMessages(), then we get the next error object per each message in the catch :

{
  name: "ServiceBusError",
  retryable: false,
  info: null,
  code: "ServiceCommunicationProblem",
  message: "The response link 'd7a6486c-5cf7-bd4a-93e0-9225e1299ffa' was not found in the entity management node $management."
}
David-Nash-0 commented 11 months ago

Any updates on this? I am getting this error in the Azure Portal when I try to Peek the message queue. The queue won't populate at all in the Portal.

EDIT: The error occurs when I attempt to Peek the messages in the queue via the Azure Portal when the Queue State is ReceiveDisabled.

jeremymeng commented 11 months ago

@AndyM1H the original issue may have been addressed by PR #25297. Could you please give version 7.9.0 or later a try?

@David-Nash-0 Do you have the stack trace? Also for Azure Portal scenarios you may want to open a support ticket so we can investigate both the Portal and the SDK.

David-Nash-0 commented 11 months ago

@jeremymeng When I click the "Peek from start" button in Service Bus Explorer, I get a notification: Failed to peek messages ServiceBusError: The response link '{guid}' was not found in the entity management node $management.

jeremymeng commented 11 months ago

@David-Nash-0 Thanks I can see the same error in portal too and will investigate this further.

jeremymeng commented 11 months ago

@David-Nash-0 when you set Queue to ReceiveDisabled you will not be able to receive messages from it. This looks to include peeking as well.

Regarding the eerror: our JS SDK receives this error first from the service

Messaging entity 'sb://yu-servicebus.servicebus.windows.net/qjs25258/$management' is currently disabled.

But due to the current architecture of the internal management client, we only log a warning for this error and are unable to surface this error to the caller of peekMessages(). So our code continues until we got another error from the service, which is the one you are seeing. I will investigate further on how to correctly report the first error.

David-Nash-0 commented 11 months ago

@jeremymeng Thank you so much for investigating. Service Bus really should allow peeking messages in the disabled states. There are operational reasons people will want to analyze the contents of the queue before releasing it for processing.

jeremymeng commented 11 months ago

Service Bus really should allow peeking messages in the disabled states. There are operational reasons people will want to analyze the contents of the queue before releasing it for processing.

@David-Nash-0 This is a good feedback! I will communicate it to the service team.