Skip to content

Fix(android): Resolve promise for loadWithKeys - #145

Open
simonljus wants to merge 1 commit into
capacitor-community:masterfrom
Pushappy:fix/android-loadwithkeys-resolve-promise
Open

Fix(android): Resolve promise for loadWithKeys#145
simonljus wants to merge 1 commit into
capacitor-community:masterfrom
Pushappy:fix/android-loadwithkeys-resolve-promise

Conversation

@simonljus

Copy link
Copy Markdown

The plugin method loadWithKeys returns a Promise<void> but compared to the other plugin methods, it never resolves.

If a user of a plugin expect the method to resolve, the code will hang indefinitely until some sort of timeout handles it.

Here is also a suggestion for a workaround that would still work after the changes in this PR (the timeoutMs should be tweaked)

let timeoutId: ReturnType<typeof setTimeout>;
const timeout = new Promise((resolve) => (timeoutId = setTimeout(resolve, 5000)));
await Promise.race([
  Intercom.loadWithKeys({ appId, apiKeyAndroid, apiKeyIOS }).finally(() => clearTimeout(timeoutId)),
  timeout,
]);

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