node-ble icon indicating copy to clipboard operation
node-ble copied to clipboard

Fix memory leak in waitDevice method

Open Raffone17 opened this issue 1 year ago • 3 comments

In the waitDevice method, if the device is not found the 'operation timed out' error is thrown but the interval is not cleared. I added a try and finally statements for avoid this problem.

Raffone17 avatar Sep 17 '24 08:09 Raffone17

Hello @chrvadala,

Please let us know when you plan to have a look at this PR by @Raffone17. Thank you!

gmacario avatar Oct 15 '24 14:10 gmacario

Thanks for this PR guys, can you integrate it with a test? I see that the fix makes completely sense, but it is better to cover this case with a test. You can mock getDevice for that. It seems the easier solution

chrvadala avatar Oct 16 '24 05:10 chrvadala

Hello @chrvadala, I did a unit test that covers the scenario.

Raffone17 avatar Oct 16 '24 09:10 Raffone17

@chrvadala I made the requested changes.

Raffone17 avatar Oct 30 '24 13:10 Raffone17

Released with v1.12.0 Thanks @Raffone17 and @gmacario for your help on this project

chrvadala avatar Nov 10 '24 19:11 chrvadala