We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
async
1 parent 279be8d commit cf31fbeCopy full SHA for cf31fbe
1 file changed
packages/wxt/src/core/utils/network.ts
@@ -1,12 +1,18 @@
1
import dns from 'node:dns';
2
import { ResolvedConfig } from '../../types';
3
import { withTimeout } from './time';
4
+import consola from 'consola';
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);
+async function isOffline(): Promise<boolean> {
+ try {
+ const isOffline = new Promise<boolean>((res) => {
+ 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
+ }
16
}
17
18
export async function isOnline(): Promise<boolean> {
0 commit comments