(source, message, timeout = 15000)
| 373 | } |
| 374 | |
| 375 | function queueCommand(source, message, timeout = 15000) { |
| 376 | return new Promise((resolve, reject) => { |
| 377 | const timer = setTimeout(() => { |
| 378 | pendingCommands.delete(source); |
| 379 | reject(new Error(`Content script on ${source} did not respond in ${timeout / 1000}s. Try refreshing the tab and retry.`)); |
| 380 | }, timeout); |
| 381 | pendingCommands.set(source, { message, resolve, reject, timer }); |
| 382 | console.log(LOG_PREFIX, `Command queued for ${source} (waiting for ready)`); |
| 383 | }); |
| 384 | } |
| 385 | |
| 386 | function flushCommand(source, tabId) { |
| 387 | const pending = pendingCommands.get(source); |
no outgoing calls
no test coverage detected