From 85fcbb3733b238fe1079589dabe0bfc8b7327480 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Fri, 24 May 2024 15:57:03 -0700 Subject: [PATCH] [ServiceBus] upgrade dependency @azure/abort-controller to ^2.1.2 (#29807) - fix compilation errors - fix v7-beta sample tagetting version --- common/config/rush/pnpm-lock.yaml | 2 +- sdk/servicebus/service-bus/CHANGELOG.md | 2 + sdk/servicebus/service-bus/package.json | 2 +- .../samples-dev/advanced/sessionRoundRobin.ts | 1 - .../samples/v7-beta/javascript/package.json | 2 +- .../samples/v7-beta/typescript/package.json | 2 +- .../samples/v7/javascript/package.json | 2 +- .../samples/v7/typescript/package.json | 2 +- .../src/advanced/sessionRoundRobin.ts | 1 - .../service-bus/src/core/managementClient.ts | 20 +++++---- .../test/internal/batchReceiver.spec.ts | 1 - .../internal/connectionManagement.spec.ts | 1 - .../internal/operationOptionsForATOM.spec.ts | 45 +++++++++---------- .../internal/unit/batchingReceiver.spec.ts | 1 - .../internal/unit/linkentity.unittest.spec.ts | 2 +- .../internal/unit/serviceBusClient.spec.ts | 2 +- .../test/internal/unit/utils.spec.ts | 2 +- .../test/public/sendAndSchedule.spec.ts | 1 - .../test/public/sessionsTests.spec.ts | 1 - .../stress/app/src/scenarioLongRunning.ts | 2 +- 20 files changed, 46 insertions(+), 48 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 0d0b21b6d24..f5665280e6f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -15371,7 +15371,7 @@ packages: rimraf: 5.0.7 ts-node: 10.9.2(@types/node@18.19.33)(typescript@5.4.5) tslib: 2.6.2 - tsx: 4.10.2 + tsx: 4.10.5 typescript: 5.4.5 uglify-js: 3.17.4 transitivePeerDependencies: diff --git a/sdk/servicebus/service-bus/CHANGELOG.md b/sdk/servicebus/service-bus/CHANGELOG.md index b1b17ecb084..681664280d2 100644 --- a/sdk/servicebus/service-bus/CHANGELOG.md +++ b/sdk/servicebus/service-bus/CHANGELOG.md @@ -12,6 +12,8 @@ ### Other Changes +- upgrade dependency `@azure/abort-controller` version to `^2.1.2`. + ## 7.9.4 (2024-02-06) ### Bugs Fixed diff --git a/sdk/servicebus/service-bus/package.json b/sdk/servicebus/service-bus/package.json index ed593eeac75..90987d387e7 100644 --- a/sdk/servicebus/service-bus/package.json +++ b/sdk/servicebus/service-bus/package.json @@ -99,7 +99,7 @@ ] }, "dependencies": { - "@azure/abort-controller": "^1.0.0", + "@azure/abort-controller": "^2.1.2", "@azure/core-amqp": "^4.2.2", "@azure/core-auth": "^1.3.0", "@azure/core-client": "^1.0.0", diff --git a/sdk/servicebus/service-bus/samples-dev/advanced/sessionRoundRobin.ts b/sdk/servicebus/service-bus/samples-dev/advanced/sessionRoundRobin.ts index 29c831fb0f6..f45bcfc2fb8 100644 --- a/sdk/servicebus/service-bus/samples-dev/advanced/sessionRoundRobin.ts +++ b/sdk/servicebus/service-bus/samples-dev/advanced/sessionRoundRobin.ts @@ -19,7 +19,6 @@ import { isServiceBusError, } from "@azure/service-bus"; import * as dotenv from "dotenv"; -import { AbortController } from "@azure/abort-controller"; dotenv.config(); diff --git a/sdk/servicebus/service-bus/samples/v7-beta/javascript/package.json b/sdk/servicebus/service-bus/samples/v7-beta/javascript/package.json index 8866d8cb2db..fb41eeaefdb 100644 --- a/sdk/servicebus/service-bus/samples/v7-beta/javascript/package.json +++ b/sdk/servicebus/service-bus/samples/v7-beta/javascript/package.json @@ -25,7 +25,7 @@ }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/servicebus/service-bus", "dependencies": { - "@azure/service-bus": "next", + "@azure/service-bus": "7.8.1-beta.1", "dotenv": "latest", "ws": "^8.0.0", "https-proxy-agent": "^7.0.0", diff --git a/sdk/servicebus/service-bus/samples/v7-beta/typescript/package.json b/sdk/servicebus/service-bus/samples/v7-beta/typescript/package.json index 791b22ff8a0..67f19ff5ebc 100644 --- a/sdk/servicebus/service-bus/samples/v7-beta/typescript/package.json +++ b/sdk/servicebus/service-bus/samples/v7-beta/typescript/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/servicebus/service-bus", "dependencies": { - "@azure/service-bus": "next", + "@azure/service-bus": "7.8.1-beta.1", "dotenv": "latest", "ws": "^8.0.0", "https-proxy-agent": "^7.0.0", diff --git a/sdk/servicebus/service-bus/samples/v7/javascript/package.json b/sdk/servicebus/service-bus/samples/v7/javascript/package.json index 4a190bf42fa..3b1d90f31a5 100644 --- a/sdk/servicebus/service-bus/samples/v7/javascript/package.json +++ b/sdk/servicebus/service-bus/samples/v7/javascript/package.json @@ -31,6 +31,6 @@ "https-proxy-agent": "^7.0.0", "@azure/identity": "^4.0.1", "@azure/core-auth": "^1.3.0", - "@azure/abort-controller": "^1.0.0" + "@azure/abort-controller": "^2.1.2" } } diff --git a/sdk/servicebus/service-bus/samples/v7/typescript/package.json b/sdk/servicebus/service-bus/samples/v7/typescript/package.json index e37c25cc683..dc022b5b8c1 100644 --- a/sdk/servicebus/service-bus/samples/v7/typescript/package.json +++ b/sdk/servicebus/service-bus/samples/v7/typescript/package.json @@ -35,7 +35,7 @@ "https-proxy-agent": "^7.0.0", "@azure/identity": "^4.0.1", "@azure/core-auth": "^1.3.0", - "@azure/abort-controller": "^1.0.0" + "@azure/abort-controller": "^2.1.2" }, "devDependencies": { "@types/ws": "^7.2.4", diff --git a/sdk/servicebus/service-bus/samples/v7/typescript/src/advanced/sessionRoundRobin.ts b/sdk/servicebus/service-bus/samples/v7/typescript/src/advanced/sessionRoundRobin.ts index f6339023342..9224f72721f 100644 --- a/sdk/servicebus/service-bus/samples/v7/typescript/src/advanced/sessionRoundRobin.ts +++ b/sdk/servicebus/service-bus/samples/v7/typescript/src/advanced/sessionRoundRobin.ts @@ -18,7 +18,6 @@ import { isServiceBusError, } from "@azure/service-bus"; import * as dotenv from "dotenv"; -import { AbortController } from "@azure/abort-controller"; dotenv.config(); diff --git a/sdk/servicebus/service-bus/src/core/managementClient.ts b/sdk/servicebus/service-bus/src/core/managementClient.ts index a23233f37d9..7abe9ced334 100644 --- a/sdk/servicebus/service-bus/src/core/managementClient.ts +++ b/sdk/servicebus/service-bus/src/core/managementClient.ts @@ -49,7 +49,7 @@ import { import { max32BitNumber } from "../util/constants"; import { Buffer } from "buffer"; import { OperationOptionsBase } from "./../modelsToBeSharedWithEventHubs"; -import { AbortController, AbortSignalLike } from "@azure/abort-controller"; +import { AbortSignalLike } from "@azure/abort-controller"; import { ReceiveMode } from "../models"; import { translateServiceBusError } from "../serviceBusError"; import { defaultDataTransformer, tryToJsonDecode } from "../dataTransformer"; @@ -265,23 +265,27 @@ export class ManagementClient extends LinkEntity { `${this.logPrefix} new replyTo address: ${this.replyTo} generated`, ); } - const { abortSignal } = options ?? {}; + const { abortSignal } = options; const aborter = new AbortController(); - const { signal } = new AbortController([ - aborter.signal, - ...(abortSignal ? [abortSignal] : []), - ]); + + const abortListener = () => { + aborter.abort(); + }; + abortSignal?.addEventListener("abort", abortListener); if (!this.isOpen()) { await Promise.race([ - this._init(signal), + this._init(aborter.signal), delay(retryTimeoutInMs, { abortSignal: aborter.signal }).then(() => { throw { name: "OperationTimeoutError", message: "The management request timed out. Please try again later.", }; }), - ]).finally(() => aborter.abort()); + ]).finally(() => { + aborter.abort(); + abortSignal?.removeEventListener("abort", abortListener); + }); } // time taken by the init operation diff --git a/sdk/servicebus/service-bus/test/internal/batchReceiver.spec.ts b/sdk/servicebus/service-bus/test/internal/batchReceiver.spec.ts index a10f5ad46af..d8cac69e05a 100644 --- a/sdk/servicebus/service-bus/test/internal/batchReceiver.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/batchReceiver.spec.ts @@ -17,7 +17,6 @@ import { getRandomTestClientType, getRandomTestClientTypeWithSessions, } from "../public/utils/testutils2"; -import { AbortController } from "@azure/abort-controller"; import { Receiver, ReceiverEvents } from "rhea-promise"; import { ServiceBusSessionReceiver, diff --git a/sdk/servicebus/service-bus/test/internal/connectionManagement.spec.ts b/sdk/servicebus/service-bus/test/internal/connectionManagement.spec.ts index 5671646b022..2fc7a485ee2 100644 --- a/sdk/servicebus/service-bus/test/internal/connectionManagement.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/connectionManagement.spec.ts @@ -9,7 +9,6 @@ // import { defaultLock } from "@azure/core-amqp"; // import { TestClientType } from "./utils/testUtils"; // import { ServiceBusSenderImpl } from "../src/sender"; -// import { AbortController } from "@azure/abort-controller"; // chai.use(chaiAsPromised); diff --git a/sdk/servicebus/service-bus/test/internal/operationOptionsForATOM.spec.ts b/sdk/servicebus/service-bus/test/internal/operationOptionsForATOM.spec.ts index 2f908611b23..90917d23ba2 100644 --- a/sdk/servicebus/service-bus/test/internal/operationOptionsForATOM.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/operationOptionsForATOM.spec.ts @@ -7,7 +7,6 @@ import chaiAsPromised from "chai-as-promised"; import chaiExclude from "chai-exclude"; import { ServiceBusAdministrationClient } from "../../src"; import { EnvVarNames, getEnvVars } from "../public/utils/envVarUtils"; -import { AbortController } from "@azure/abort-controller"; import { createPipelineRequest } from "@azure/core-rest-pipeline"; import { executeAtomXmlOperation } from "../../src/util/atomXmlHelper"; import { NamespaceResourceSerializer } from "../../src/serializers/namespaceResourceSerializer"; @@ -38,119 +37,119 @@ describe("Operation Options", () => { it("getNamespaceProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getNamespaceProperties({ - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("createQueue", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.createQueue(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getQueue", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getQueue(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("updateQueue", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.updateQueue({ name: entityName1 } as any, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("deleteQueue", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.deleteQueue(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getQueueRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getQueueRuntimeProperties(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getQueues", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getQueues"]({ - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getQueuesRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getQueuesRuntimeProperties"]({ - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("createTopic", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.createTopic(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getTopic", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getTopic(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("updateTopic", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.updateTopic({ name: entityName1 } as any, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("deleteTopic", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.deleteTopic(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getTopicRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getTopicRuntimeProperties(entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getTopics", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getTopics"]({ - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getTopicsRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getTopicsRuntimeProperties"]({ - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("createSubscription", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.createSubscription(entityName1, entityName2, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getSubscription", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getSubscription(entityName1, entityName2, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); @@ -159,7 +158,7 @@ describe("Operation Options", () => { serviceBusAtomManagementClient.updateSubscription( { topicName: entityName1, subscriptionName: entityName2 } as any, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }, ), ); @@ -167,28 +166,28 @@ describe("Operation Options", () => { it("deleteSubscription", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.deleteSubscription(entityName1, entityName2, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getSubscriptionRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient.getSubscriptionRuntimeProperties(entityName1, entityName2, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getSubscriptions", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getSubscriptions"](entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); it("getSubscriptionsRuntimeProperties", async () => { await verifyAbortError(async () => serviceBusAtomManagementClient["getSubscriptionsRuntimeProperties"](entityName1, { - abortSignal: AbortController.timeout(1), + abortSignal: AbortSignal.timeout(1), }), ); }); diff --git a/sdk/servicebus/service-bus/test/internal/unit/batchingReceiver.spec.ts b/sdk/servicebus/service-bus/test/internal/unit/batchingReceiver.spec.ts index bff064100d6..aa998655121 100644 --- a/sdk/servicebus/service-bus/test/internal/unit/batchingReceiver.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/unit/batchingReceiver.spec.ts @@ -16,7 +16,6 @@ import { } from "../../../src/core/batchingReceiver"; import { defer, createConnectionContextForTests } from "./unittestUtils"; import { createAbortSignalForTest } from "../../public/utils/abortSignalTestUtils"; -import { AbortController } from "@azure/abort-controller"; import { ServiceBusMessageImpl } from "../../../src/serviceBusMessage"; import { Receiver as RheaPromiseReceiver, diff --git a/sdk/servicebus/service-bus/test/internal/unit/linkentity.unittest.spec.ts b/sdk/servicebus/service-bus/test/internal/unit/linkentity.unittest.spec.ts index d51b9149e78..5552ca9c74a 100644 --- a/sdk/servicebus/service-bus/test/internal/unit/linkentity.unittest.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/unit/linkentity.unittest.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { AbortController, AbortSignalLike } from "@azure/abort-controller"; +import { AbortSignalLike } from "@azure/abort-controller"; import chai from "chai"; import chaiAsPromised from "chai-as-promised"; import { Receiver, ReceiverOptions } from "rhea-promise"; diff --git a/sdk/servicebus/service-bus/test/internal/unit/serviceBusClient.spec.ts b/sdk/servicebus/service-bus/test/internal/unit/serviceBusClient.spec.ts index a97d38879b7..ca97a212bcc 100644 --- a/sdk/servicebus/service-bus/test/internal/unit/serviceBusClient.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/unit/serviceBusClient.spec.ts @@ -16,7 +16,7 @@ import { ServiceBusSessionReceiver, ServiceBusSessionReceiverImpl, } from "../../../src/receivers/sessionReceiver"; -import { AbortController, AbortSignalLike } from "@azure/abort-controller"; +import { AbortSignalLike } from "@azure/abort-controller"; import { ServiceBusSenderImpl } from "../../../src/sender"; import { MessageReceiver } from "../../../src/core/messageReceiver"; const assert: typeof chai.assert = chai.assert; diff --git a/sdk/servicebus/service-bus/test/internal/unit/utils.spec.ts b/sdk/servicebus/service-bus/test/internal/unit/utils.spec.ts index aef85418a5f..90b3ada838e 100644 --- a/sdk/servicebus/service-bus/test/internal/unit/utils.spec.ts +++ b/sdk/servicebus/service-bus/test/internal/unit/utils.spec.ts @@ -6,7 +6,7 @@ import { waitForTimeoutOrAbortOrResolve, } from "../../../src/util/utils"; import { StandardAbortMessage } from "@azure/core-amqp"; -import { AbortController, AbortError, AbortSignalLike } from "@azure/abort-controller"; +import { AbortError, AbortSignalLike } from "@azure/abort-controller"; import { delay } from "rhea-promise"; import chai from "chai"; import chaiAsPromised from "chai-as-promised"; diff --git a/sdk/servicebus/service-bus/test/public/sendAndSchedule.spec.ts b/sdk/servicebus/service-bus/test/public/sendAndSchedule.spec.ts index 97afa9ccdc0..67e34aa8742 100644 --- a/sdk/servicebus/service-bus/test/public/sendAndSchedule.spec.ts +++ b/sdk/servicebus/service-bus/test/public/sendAndSchedule.spec.ts @@ -20,7 +20,6 @@ import { getRandomTestClientType, } from "./utils/testutils2"; import { ServiceBusSender } from "../../src"; -import { AbortController } from "@azure/abort-controller"; import { StandardAbortMessage } from "@azure/core-amqp"; const noSessionTestClientType = getRandomTestClientTypeWithNoSessions(); diff --git a/sdk/servicebus/service-bus/test/public/sessionsTests.spec.ts b/sdk/servicebus/service-bus/test/public/sessionsTests.spec.ts index dfd21131dd9..5c7f4e2e054 100644 --- a/sdk/servicebus/service-bus/test/public/sessionsTests.spec.ts +++ b/sdk/servicebus/service-bus/test/public/sessionsTests.spec.ts @@ -25,7 +25,6 @@ import { testPeekMsgsLength, getRandomTestClientTypeWithSessions, } from "./utils/testutils2"; -import { AbortController } from "@azure/abort-controller"; import sinon from "sinon"; import { ServiceBusSessionReceiverImpl } from "../../src/receivers/sessionReceiver"; diff --git a/sdk/servicebus/service-bus/test/stress/app/src/scenarioLongRunning.ts b/sdk/servicebus/service-bus/test/stress/app/src/scenarioLongRunning.ts index 2d161f4e7b3..5ac7b2772cd 100644 --- a/sdk/servicebus/service-bus/test/stress/app/src/scenarioLongRunning.ts +++ b/sdk/servicebus/service-bus/test/stress/app/src/scenarioLongRunning.ts @@ -7,7 +7,7 @@ import { loopForever as loopInfinitely, ServiceBusStressTester, } from "./serviceBusStressTester"; -import { AbortController, AbortSignalLike } from "@azure/abort-controller"; +import { AbortSignalLike } from "@azure/abort-controller"; import { ServiceBusClient, ServiceBusSender } from "@azure/service-bus"; import { v4 as uuidv4 } from "uuid";