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

Add timeout for sendMessage #53

Open
NoamLoewenstern opened this issue Mar 20, 2023 · 1 comment
Open

Add timeout for sendMessage #53

NoamLoewenstern opened this issue Mar 20, 2023 · 1 comment

Comments

@NoamLoewenstern
Copy link
Contributor

I would find it useful to add an option for timeout waiting for response, when calling "sendMessage".
Something like this:

const resp = await sendMessage('messageID', { msgData: 'data' }, `content-script@123`, { timeout: 3000 })
@zikaari
Copy link
Collaborator

zikaari commented Mar 24, 2023

That's a good idea. While I don't have the resources at this time to implement it in the library, this should work as quick-workaround:

 This code snippet has not been tested

import pTimeout from 'p-timeout'

try {
  const resp = await pTimeout(
    sendMessage('messageID', { msgData: 'data' }, `content-script@123`),
    { milliseconds: 3000 }
  )
} catch (err) {
  // [TimeoutError: Promise timed out after 3000 milliseconds]
}

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

No branches or pull requests

2 participants