aws-sdk-js icon indicating copy to clipboard operation
aws-sdk-js copied to clipboard

IoT SDK deleteThingGroup promises on child groups succeed before actually doing it, causing the parent deletion to fail

Open teuteuguy opened this issue 3 years ago • 4 comments

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug Raised this to AWS support who suggested raising a github issues for this. When using thingGroups in IoT Core, and needing to clean up, the deletion of a parent requires you to delete the child groups. When attempting to do that from a lambda function in javascript using the sdk, and promises, the promise for deletion of a thinggroup resolves meaning that it "should" be done. Code moves on to deleting the parent, which fails because the child is still present either from an SDK resolving too fast, or because backend doesnt have time to finish actually properly deleting the child.

Is the issue in the browser/Node.js? Node.js

If on Node.js, are you running this on AWS Lambda? Yes

Details of the browser/Node.js version 14.x

SDK version number Whatever run time in the lambdas.

To Reproduce (observed behavior) Simply create a parent thingGruop and a child Thinggroup and try to delete them one after the other from lambda code, using promises (await iot.deleteThingGroup(...).promise().then(() => { console.log('group deleted');});)

Expected behavior the then should only occurr once the deletion is complete and we can move on !

Screenshots If applicable, add screenshots to help explain your problem.

Additional context According to support, this does not happen with the CLI

teuteuguy avatar Feb 03 '22 16:02 teuteuguy

SDK version number Currently, Lambda is using version "2.1001.0" https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

In order to isolate the issue, I attempted the delete thing group using CLI commands in a bash script and observed that I didn't had to add any delays. It seems that the issue is only with Javascript SDK and other SDKs work as expected.

sumit2593 avatar Feb 03 '22 16:02 sumit2593

Hi @sumit2593 thanks for the information. Can you provide reproducible code that we can use to investigate this?

vudh1 avatar Feb 19 '22 01:02 vudh1

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] avatar Feb 25 '22 00:02 github-actions[bot]

Issue is easy to reproduce.

create a thing group hierarchy of parent and child’s.

then, use JavaScript sdk to deleteThingGroups one after the other starting from the children using promises

teuteuguy avatar Feb 25 '22 13:02 teuteuguy

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] avatar Mar 16 '23 00:03 github-actions[bot]