Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unfullfilled callbacks when gatt is null #1297

Merged
merged 11 commits into from
Jan 16, 2025

Conversation

matt-42
Copy link
Contributor

@matt-42 matt-42 commented Dec 10, 2024

This fixes issue #1291 and a null exception.

@marcosinigaglia
Copy link
Member

Hi @matt-42 , are you sure that is the correct fix? Have you test it?

@matt-42
Copy link
Contributor Author

matt-42 commented Dec 10, 2024

Yes, I've tested it and my connection problems got solved, and I did not have null pointer exceptions. gatt is checked almost everywhere. I'll add more check just in case.
There may be more problems though, since commandQueue.clear(); is called in other places without properly calling all the callbacks with an error message.

@matt-42
Copy link
Contributor Author

matt-42 commented Dec 10, 2024

I've changed a bit my PR so the callbacks get cleared as soon as we got the gatt is null error, also added error checking in onServicesDiscovered.

@marcosinigaglia
Copy link
Member

Thanks @matt-42 , let me know when you think is ready to merge.

@matt-42
Copy link
Contributor Author

matt-42 commented Dec 11, 2024

ok :). I'll tell you when I'm done doing fixes.

@matt-42
Copy link
Contributor Author

matt-42 commented Jan 15, 2025

I'm done with my work. I did not have issues of hanging promises anymore and I did not break anything in my app. Feel free to merge it when you think it is the right time to do so :)

@marcosinigaglia marcosinigaglia merged commit 6711839 into innoveit:master Jan 16, 2025
vhakulinen pushed a commit to vhakulinen/react-native-ble-manager that referenced this pull request Jan 21, 2025
vhakulinen pushed a commit to vhakulinen/react-native-ble-manager that referenced this pull request Jan 21, 2025
@vhakulinen
Copy link
Contributor

vhakulinen commented Jan 29, 2025

After trying to fix similar issue in #1321 for v11, I came to realization that there is still at least one way for callbacks to say floating / unfulfilled: when a read call (or any other enqueued "command") is issued to a disconnected peripheral, nextCommand will notice that gatt is null and invoke errors to all callbacks. The issue here is that the errorAndClearAllCallbacks is called before the latest callback is added to the callback array (readCallbacks in case of a read).

EDIT: I guess that would be fixed by #1305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants