We will be sunsetting Advisor during Jan, 2026 and will instead be providing information in Snyk Security DB.

You can begin to take advantage of Snyk Security DB today for a unified, package-centric experience.

How to use the @azure/amqp-common.delay function in @azure/amqp-common

To help you get started, we’ve selected a few @azure/amqp-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / session / sessionManager.ts View on Github external
// the Promise is rejected. The "microsoft.timeout" error occurs when timeout happens on
        // the server side and ServiceBus sends a detach frame due to which the Promise is rejected.
        if (
          err.name === ConditionErrorNameMapper["amqp:operation-timeout"] ||
          err.name === ConditionErrorNameMapper["com.microsoft:timeout"] ||
          err.name === ConditionErrorNameMapper["com.microsoft:session-cannot-be-locked"]
        ) {
          // No point in delaying if cancel has been requested.
          if (!this._isCancelRequested) {
            log.sessionManager(
              "[%s] Sleeping for %d seconds, since there are no more active MessageSessions on " +
                "the ServiceBus entity.",
              connectionId,
              noActiveSessionBackOffInSeconds
            );
            await delay(noActiveSessionBackOffInSeconds * 1000);
          }
        } else {
          // notify the user about the error only when it is not one of the above mentioned errors.
          onError(err);
        }
      } finally {
        this._maxPendingAcceptSessionsSemaphore.release();
        log.sessionManager(
          "[%s] Releasing the semaphore for max pending accept sessions from " +
            "the finally block: %d, %d.",
          connectionId,
          this._maxPendingAcceptSessionsSemaphore.currentLockCount(),
          this._maxPendingAcceptSessionsSemaphore.awaitedTaskCount()
        );
      }
    }
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / connectionContext.ts View on Github external
const clientContext = connectionContext.clientContexts[id];
        if (clientContext.managementClient) {
          await clientContext.managementClient.close();
        }
      }

      // The connection should always be brought back up if the sdk did not call connection.close()
      // and there was atleast one sender/receiver link on the connection before it went down.
      log.error("[%s] state: %O", connectionContext.connectionId, state);
      if (!state.wasConnectionCloseCalled && state.numClients) {
        log.error(
          "[%s] connection.close() was not called from the sdk and there were some " +
            "clients. We should reconnect.",
          connectionContext.connection.id
        );
        await delay(Constants.connectionReconnectDelay);
        // reconnect clients if any
        for (const id of Object.keys(connectionContext.clientContexts)) {
          const clientContext = connectionContext.clientContexts[id];
          log.error(
            "[%s] calling detached on client '%s'.",
            connectionContext.connection.id,
            clientContext.clientId
          );
          clientContext.onDetached(connectionError || contextError).catch((err) => {
            log.error(
              "[%s] An error occurred while reconnecting the sender '%s': %O.",
              connectionContext.connection.id,
              clientContext.clientId,
              err
            );
          });
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / core / messageSender.ts View on Github external
let waitTimer: any;
        log.sender(
          "[%s] Sender '%s', credit: %d available: %d",
          this._context.namespace.connectionId,
          this.name,
          this._sender!.credit,
          this._sender!.session.outgoing.available()
        );
        if (!this._sender!.sendable()) {
          log.sender(
            "[%s] Sender '%s', waiting for 1 second for sender to become sendable",
            this._context.namespace.connectionId,
            this.name
          );
          
          await delay(1000);

          log.sender(
            "[%s] Sender '%s' after waiting for a second, credit: %d available: %d",
            this._context.namespace.connectionId,
            this.name,
            this._sender!.credit,
            this._sender!.session.outgoing.available()
          );
        }
        if (this._sender!.sendable()) {
          let onRejected: Func;
          let onReleased: Func;
          let onModified: Func;
          let onAccepted: Func;
          const removeListeners = (): void => {
            clearTimeout(waitTimer);
github Azure / azure-sdk-for-js / sdk / servicebus / service-bus / src / util / concurrentExpiringMap.ts View on Github external
private async _collectExpiredEntries(): Promise {
    if (this._map.size === 0) {
      return;
    }

    await delay(this._delayBetweenCleanupInSeconds);
    this._cleanupScheduled = false;
    for (const key of this._map.keys()) {
      if (Date.now() > this._map.get(key)!.getTime()) {
        this._map.delete(key);
        log.map("Deleted the key '%s' from the map.", key);
      }
    }
    this._scheduleCleanup().catch((err) => {
      log.error(
        "An error occurred while scheduling the cleanup, after " + "collecting expired entries: %O",
        err
      );
    });
  }