Skip to content

Commit 830f970

Browse files
committed
fix: not to reject if timeout sendMsg2Runtime
1 parent 9fb3c0b commit 830f970

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/api/chrome/runtime.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ function cloneData<T = any>(data: T | undefined): T | undefined {
2424
export function sendMsg2Runtime<T = any, R = any>(code: timer.mq.ReqCode, data?: T): Promise<R | undefined> {
2525
const request: timer.mq.Request<T> = { code, data: cloneData(data) }
2626
return new Promise((resolve, reject) => {
27-
const timeout = setTimeout(() => reject(new Error('Message timeout: no response from runtime')), 10_000)
27+
const timeout = setTimeout(() => {
28+
// timeout: no response from runtime
29+
resolve(undefined)
30+
}, 10_000)
2831
try {
2932
chrome.runtime.sendMessage(request, (response: timer.mq.Response<R>) => {
3033
clearTimeout(timeout)

0 commit comments

Comments
 (0)