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

feat: share deviceType with local peers #461

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

gmaclennan
Copy link
Member

fixes #451 and #452. Does not store deviceType in project deviceInfo
records, which will be done in a follow up PR (see #455) which also
requires changes to @mapeo/schema. deviceType is optional, and must be
set in the constructor of MapeoManager. Ideally this should not be
possible to change, but not sure how to enforce that.

fixes #451 and #452. Does not store deviceType in project deviceInfo
records, which will be done in a follow up PR (see #455) which also
requires changes to @mapeo/schema. `deviceType` is optional, and must be
set in the constructor of MapeoManager. Ideally this should not be
possible to change, but not sure how to enforce that.
@gmaclennan gmaclennan self-assigned this Jan 31, 2024
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than my small comments and questions.

proto/rpc.proto Show resolved Hide resolved
src/local-peers.js Show resolved Hide resolved
src/mapeo-manager.js Show resolved Hide resolved
test-e2e/local-peers.js Outdated Show resolved Hide resolved
test-e2e/local-peers.js Show resolved Hide resolved
test-e2e/local-peers.js Outdated Show resolved Hide resolved
tests/local-peers.js Outdated Show resolved Hide resolved
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than my one nitpick.

Comment on lines 14 to 16
t.teardown(() => {
disconnectPeers(managers)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think this callback should return a promise. One of these should work:

Suggested change
t.teardown(() => {
disconnectPeers(managers)
})
t.teardown(async () => {
await disconnectPeers(managers)
})

...or:

Suggested change
t.teardown(() => {
disconnectPeers(managers)
})
t.teardown(() => disconnectPeers(managers))

The latter doesn't immediately work because the callback to t.teardown() is expected to return void | Promise<void>, but disconnectPeers returns Promise<void[]>. I'd fix that by updating test-e2e/utils.js like this:

diff --git a/test-e2e/utils.js b/test-e2e/utils.js
index e5fd403..7dd5575 100644
--- a/test-e2e/utils.js
+++ b/test-e2e/utils.js
@@ -24,7 +24,7 @@ const clientMigrationsFolder = new URL('../drizzle/client', import.meta.url)
  * @param {readonly MapeoManager[]} managers
  */
 export async function disconnectPeers(managers) {
-  return Promise.all(
+  await Promise.all(
     managers.map(async (manager) => {
       return manager.stopLocalPeerDiscovery({ force: true })
     })

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh this is where typescript annoys me. It gave the error when writing it the original way, and to keep it happy I added the braces, which ends up introducing this bug. Good example of typescript prompting me to write buggy code when how I wrote it (which errors typescript) would not actually cause any bugs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it works for us, but we might be able to enable a "no floating promises" ESLint rule to help with this kind of problem.

@gmaclennan gmaclennan merged commit 4a2cb3c into main Feb 8, 2024
6 of 7 checks passed
@gmaclennan gmaclennan deleted the feat/local-peer-device-type branch February 8, 2024 11:33
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.

Add deviceType to local peer discovery
2 participants