aws-sdk-js
aws-sdk-js copied to clipboard
IoT SDK deleteThingGroup promises on child groups succeed before actually doing it, causing the parent deletion to fail
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- [x] I've gone through Developer Guide and API reference
- [x] I've checked AWS Forums and StackOverflow for answers
- [x] I've searched for previous similar issues and didn't find any solution
- [ ] This is an issue with version 2.x of the SDK
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
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.
Hi @sumit2593 thanks for the information. Can you provide reproducible code that we can use to investigate this?
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.
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
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.