Skip to content

Fix “unknown peripheral null connected!” warning#62

Open
dnicolson wants to merge 1 commit intostoprocent:mainfrom
dnicolson:fix-unknown-peripheral-warning
Open

Fix “unknown peripheral null connected!” warning#62
dnicolson wants to merge 1 commit intostoprocent:mainfrom
dnicolson:fix-unknown-peripheral-warning

Conversation

@dnicolson
Copy link

This fixes a race condition when cancelConnect() is called immediately, and the connection queue can be emptied before the controller completes with an error. Previously, this caused uuid to be null in the connect event, triggering the "unknown peripheral null connected!" warning.

This code can reproduce the warning:

const noble = require('@stoprocent/noble');

const MAC = '112233445566';

async function main() {
  await noble.waitForPoweredOnAsync();
  setTimeout(() => noble.cancelConnect(MAC), 10);
  await noble.connectAsync(MAC).catch(() => {});
}

main();

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant