Skip to content

Commit

Permalink
fix: error log
Browse files Browse the repository at this point in the history
  • Loading branch information
isaurssaurav committed Sep 24, 2023
1 parent ef17803 commit a81206a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/scripts/background-reload.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { HOT_RELOAD_EXTENSION_VITE_PORT, Message, isDev } from '../utils';

if (isDev) {
const socket = new WebSocket(
`ws://localhost:${HOT_RELOAD_EXTENSION_VITE_PORT}`
);
try {
const socket = new WebSocket(
`ws://localhost:${HOT_RELOAD_EXTENSION_VITE_PORT}`
);

socket.addEventListener('message', (event) => {
if (event.data === Message.FILE_CHANGE) {
chrome.runtime.reload();
chrome.tabs.reload();
}
});
socket.addEventListener('message', (event) => {
if (event.data === Message.FILE_CHANGE) {
chrome.runtime.reload();
chrome.tabs.reload();
}
});
} catch (e) {
console.info('Please run `npm run dev` to start socket.', e);
}
}

0 comments on commit a81206a

Please sign in to comment.