question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event Grid - No failure case when publishing events

See original GitHub issue

Hi,

I am using nodejs library for Event Grid (azure-eventgrid).

If I provide wrong values for Topic Endpoint or Access Key parts, publishing events doesn’t fail as expected. It doesn’t output anything for neither then or catch part.

I am using this in a Azure Functions component.

let topicCreds = new msRestAzure.TopicCredentials(EVENT_GRID_ACCESS_KEY);
let egClient = new eventGrid(topicCreds);
let topicUrl = url.parse(EVENT_GRID_TOPIC_ENDPOINT, true);
let topicHostName = topicUrl.host;

egClient.publishEvents(topicHostName, events).then((result) => {
    context.log.info('Published all events to Event Grid!')
}).catch((err) => {
    context.log.error('Event Grid publishing events error: ' + err);
});

How can I fetch failure cases?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mustafababilcommented, Feb 13, 2020

Thank you @chradek. Now I got what I expect. Thanks for your time. @ramya-rao-a I am closing the issue as @chradek helped me a lot.

0reactions
chradekcommented, Feb 12, 2020

@mustafababil I believe the issue is because you’re calling context.done() at the bottom of your function outside of your publishEvents call. Since publishEvents is non-blocking, execution will continue to the end of your function before your then or catch handlers are invoked.

Since you’re already using an async function, you can use await with publishEvents instead to get the affect you want:

try {
  const result  = await egClient.publishEvents(topicHostName, events);
  let message = `Published all events to Event Grid with Event Type '${EVENT_GRID_PUBLISH_EVENT_TYPE}'.`;
  context.log.info(message);
} catch (error) {
  let message = `Error in publishing events to Event Grid: ${error}`;
  context.done(message);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Event Grid message delivery and retry - Azure - Microsoft Learn
Describes how Azure Event Grid delivers events and how it handles undelivered messages.
Read more >
Azure Event Grid — Handling Failures | by Mike Rogers
All you can do is store the failed events in a storage account. A process known as dead-lettering. Resubmit failed events. There is...
Read more >
How to determine cause of Azure EventGrid message delivery ...
It appears the only way to determine why an Event Grid message failed to be delivered is to turn on Dead Lettering.
Read more >
Event Grid Delivery and Retry Policy | Serverless360
For any reason, if the Event Subscription fails to receive the events, there is a Dead-lettering mechanism available to capture the failed ......
Read more >
Azure Event Grid vs Service Bus - LinkedIn
In the case of Microservices Architecture, one of the common ... Event Grid does not guarantee the order of Events delivery whereas with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found