Skip to content
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

[Event Hubs] AbortSignal for createBatch does not abort the program #9202

Closed
ramya-rao-a opened this issue Jun 1, 2020 · 2 comments
Closed
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs

Comments

@ramya-rao-a
Copy link
Contributor

In the below code snippet, the abort signal is set to be fired in the event loop after createBatch is called. The expectation is that createBatch throws the AbortError and the program exits.

While we do see the AbortError being fired, the program does not exit

import { EventHubProducerClient } from "@azure/event-hubs";
import { AbortController } from "@azure/abort-controller";

async function main() {
  const producerClient = new EventHubProducerClient(connectionString, eventHubName);
  const abortSignal = AbortController.timeout(0);
  try {
    await producerClient.createBatch({ abortSignal: abortSignal });
  } finally {
    await producerClient.close()
    console.log("Client closed");
  }
}

main().catch(err => {
  console.log("Found error!!");
  console.log(err);
})

When logs are enabled, we see the reason for this is that the timer is set for 45 mins for token renewal. While we know from #4422, that link initialization does not stop as rhea-promise does not support abort signals yet, we can at the very least exit the timer.

azure:event-hubs:verbose [connection-1] Created connection context successfully.
azure:event-hubs:verbose [connection-1] Sender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with address 'my-hub' is open? -> undefined
azure:event-hubs:verbose Acquiring lock sender-f676885c-60b6-40c9-a16d-649a48f1972f for initializing the session, sender and possibly the connection.
azure:event-hubs:verbose Creating sender with options: { name: 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad',
  target: { address: 'my-hub' },
  onError: [Function],
  onClose: [Function],
  onSessionError: [Function],
  onSessionClose: [Function],
  sendTimeoutInSeconds: 60 }
azure:event-hubs:verbose [connection-1] Sender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with address 'my-hub' is open? -> undefined
azure:event-hubs:verbose [connection-1] Acquiring cbs lock: 'negotiateCbs-32de13a3-19fa-fe40-9c63-21b2c1434bdd' for creating the cbs session while creating the EventHubSender: 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with address: 'my-hub'.
azure:event-hubs:info [connection-1] The create batch operation has been cancelled by the user.
Client closed
Found error!!
{ AbortError: The create batch operation has been cancelled by the user.
    at new AbortError (/Users/ramyar/Documents/GitRepos/test/node_modules/@azure/abort-controller/src/AbortController.ts:21:5)
    at rejectOnAbort (/Users/ramyar/Documents/GitRepos/test/node_modules/@azure/event-hubs/src/eventHubSender.ts:225:23)
    at AbortSignal.onAbort (/Users/ramyar/Documents/GitRepos/test/node_modules/@azure/event-hubs/src/eventHubSender.ts:233:9)
    at /Users/ramyar/Documents/GitRepos/test/node_modules/@azure/abort-controller/src/AbortSignal.ts:165:16
    at Array.forEach (<anonymous>)
    at Timeout.abortSignal (/Users/ramyar/Documents/GitRepos/test/node_modules/@azure/abort-controller/src/AbortSignal.ts:164:15)
    at ontimeout (timers.js:438:13)
    at tryOnTimeout (timers.js:300:5)
    at unrefdHandle (timers.js:520:7)
    at Timer.processTimers (timers.js:222:12) name: 'AbortError' }
azure:event-hubs:verbose [connection-1] setting 'wasConnectionCloseCalled' property of connection context to false.
azure:event-hubs:verbose [connection-1] EventHubSender: calling negotiateClaim for audience 'sb://ramyar-eh-test.servicebus.windows.net/my-hub'.
azure:event-hubs:verbose [connection-1] Acquiring cbs lock: 'negotiateClaim-67672b75-04b9-0045-9e1c-64c8a98096b6' for cbs auth for EventHubSender: 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with address 'my-hub'.
azure:event-hubs:verbose [connection-1] Negotiated claim for EventHubSender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with with address: my-hub
azure:event-hubs:verbose [connection-1] Trying to create sender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad'...
azure:event-hubs:verbose [connection-1] Sender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' created with sender options: { name: 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad',
  target: { address: 'my-hub' },
  onError: [Function],
  onClose: [Function],
  onSessionError: [Function],
  onSessionClose: [Function],
  sendTimeoutInSeconds: 60 }
azure:event-hubs:verbose [connection-1] EventHubSender 'my-hub-50e3fe69-0dfb-485c-b7ef-2f5204d8f2ad' with address my-hub, has next token renewal in 2700000 milliseconds @(Sun May 31 2020 20:47:50 GMT-0700 (Pacific Daylight Time)).
@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 1, 2020
@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Event Hubs labels Jun 1, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 1, 2020
@ramya-rao-a ramya-rao-a added this to the Backlog milestone Jun 1, 2020
@ramya-rao-a
Copy link
Contributor Author

cc @richardpark-msft, @chradek

@chradek
Copy link
Contributor

chradek commented Apr 29, 2021

This has been fixed in version 5.5.1 of event-hubs now that we've plumbed the abortSignal through all our operations (except close).

@chradek chradek closed this as completed Apr 29, 2021
@xirzec xirzec removed this from the Backlog milestone May 18, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs
Projects
None yet
Development

No branches or pull requests

4 participants