Skip to content

Commit cf31fbe

Browse files
chore: add missing async to network.ts (#2107)
1 parent 279be8d commit cf31fbe

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/wxt/src/core/utils/network.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import dns from 'node:dns';
22
import { ResolvedConfig } from '../../types';
33
import { withTimeout } from './time';
4+
import consola from 'consola';
45

5-
function isOffline(): Promise<boolean> {
6-
const isOffline = new Promise<boolean>((res) => {
7-
dns.resolve('google.com', (err) => res(err != null));
8-
});
9-
return withTimeout(isOffline, 1e3).catch(() => true);
6+
async function isOffline(): Promise<boolean> {
7+
try {
8+
const isOffline = new Promise<boolean>((res) => {
9+
dns.resolve('google.com', (err) => res(err != null));
10+
});
11+
return await withTimeout(isOffline, 1e3);
12+
} catch (error) {
13+
consola.error('Error checking offline status:', error);
14+
return true;
15+
}
1016
}
1117

1218
export async function isOnline(): Promise<boolean> {

0 commit comments

Comments
 (0)