Azure / azure-event-hubs-node

Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
50 stars 46 forks source link

awaiting in OnRecievedMessage fails #177

Closed MakerDave closed 5 years ago

MakerDave commented 5 years ago

Describe the bug In processing each message received, we want to call a webservice using axios or https modules. We cannot get them to work. Creating an async function, then calling with await or then(), the code execution appears to fail or timeout. I cannot detect any other error messages. I can reproduce it with your handy sleep() method you have included in your source.

Steps to reproduce the behavior: in the OnMessageReceived event, Add some async code like:

sleep(1).then(() => { console.log("return from sleep"); }); // Checkpointing every 100th event received for a given partition. if (partionCount[context.partitionId] % 100 === 0) { ...

Expected behavior:

The console.log("return from sleep") should be written to the log. the "if partionCount[" line should also be executed.

Package-name: azure-event-processor-host "dependencies": { "@azure/event-hubs": "^1.0.8", "async-lock": "^1.1.3", "axios": "^0.18.0", "azure-storage": "^2.10.2", "debug": "^3.1.0", "ms-rest-azure": "^2.5.7", "path-browserify": "^1.0.0", "tslib": "^1.9.3", "uuid": "^3.3.2" }, "devDependencies": {
"ts-node": "^7.0.0", "typescript": "^2.9.2"

OS name and version: Windows 10, Node v8.12.0

Additional context We have tried with the "await sleep(1)" flavor as well. After trying a few things, we found that this function "moreSleep" does not fail: const moreSleep = (seconds: any) => { return new Promise((resolve, reject) => { setTimeout(() => { resolve(); }, seconds * 1000); }); };debugadapter.zip

MakerDave commented 5 years ago

Please disregard. I see the messages now, as I reduce the time to .25 seconds.