-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] pass abortSignal to link initialization and awaitableSender #15349
Changes from 2 commits
2fa99c3
3d32c2a
9620589
15e93a3
b41e07a
f96555c
b238f3c
4ae6665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import { | |
createConnectionContextForTestsWithSessionId | ||
} from "./unittestUtils"; | ||
import { StandardAbortMessage } from "@azure/core-amqp"; | ||
import { isLinkLocked } from "../utils/misc"; | ||
import { ServiceBusSessionReceiverImpl } from "../../../src/receivers/sessionReceiver"; | ||
import { ServiceBusReceiverImpl } from "../../../src/receivers/receiver"; | ||
import { MessageSession } from "../../../src/session/messageSession"; | ||
|
@@ -162,6 +161,38 @@ describe("AbortSignal", () => { | |
assert.isTrue((err as any).retryable); | ||
} | ||
}); | ||
|
||
it("_trySend passes abortSignal to awaitable sender", async () => { | ||
const sender = new MessageSender(connectionContext, "fakeEntityPath", { | ||
timeoutInMs: 1 | ||
}); | ||
closeables.push(sender); | ||
|
||
let wasAbortSignalPassed = false; | ||
sender["_link"] = { | ||
credit: 999, | ||
isOpen: () => true, | ||
session: { | ||
outgoing: { | ||
available: () => true | ||
} | ||
}, | ||
sendable() { | ||
return true; | ||
}, | ||
send(_msg, _tag, _format, options) { | ||
if (options?.abortSignal) { | ||
wasAbortSignalPassed = true; | ||
} | ||
return Promise.resolve({}); | ||
} | ||
} as AwaitableSender; | ||
|
||
await sender["_trySend"]({} as Buffer, true, { | ||
abortSignal: createAbortSignalForTest(false) | ||
}); | ||
assert.isTrue(wasAbortSignalPassed, "abortSignal should have been passed to AwaitableSender"); | ||
}); | ||
}); | ||
|
||
describe("MessageSender.open() aborts after...", () => { | ||
|
@@ -178,8 +209,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(sender)); | ||
}); | ||
|
||
it("...afterLock", async () => { | ||
|
@@ -195,8 +224,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(sender)); | ||
}); | ||
|
||
it("...negotiateClaim", async () => { | ||
|
@@ -225,8 +252,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(sender)); | ||
}); | ||
|
||
it("...createAwaitableSender", async () => { | ||
|
@@ -255,8 +280,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a bit redundant but are the isLinkLocked calls being removed because the new cancellable lock doesn't support it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep exactly. We weren't using that API in any of our runtime code (or test code in event hubs) so I didn't implement it in the cancellable lock. We could always add it if we thought we'd gain something from it though. |
||
|
||
assert.isFalse(isLinkLocked(sender)); | ||
}); | ||
}); | ||
|
||
|
@@ -278,8 +301,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(messageReceiver)); | ||
}); | ||
|
||
it("...after negotiateClaim", async () => { | ||
|
@@ -304,8 +325,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(messageReceiver)); | ||
}); | ||
|
||
it("...after createReceiver", async () => { | ||
|
@@ -331,8 +350,6 @@ describe("AbortSignal", () => { | |
assert.equal(err.message, StandardAbortMessage); | ||
assert.equal(err.name, "AbortError"); | ||
} | ||
|
||
assert.isFalse(isLinkLocked(messageReceiver)); | ||
}); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to think about this one more.
It opens up an execution path that did not exist before. It's now possible for two _initLinkImpl's to be executing at the same time if the outer lock aborts and the inner operation is still running.
This complicates the code for _initLinkImpl a bit because it now has to be careful when unwinding state that it's not conflicting with another call of itself (which wasn't a concern before).
Do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The abortSignal can only cause the acquire call to abort if the inner function hasn't been invoked yet. As soon as that inner function is invoked, both the timeout and abortSignal on
acquire
are cancelled/removed.Does that clear up your concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does.
Looking at the doc comment the behavior you described is pretty clear for 'task', but less clear for 'abort'.