mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-21 17:16:42 +03:00
Fix DevTools from losing connection (#1767)
* Fix DevTools from losing connection * Create kind-seals-arrive.md
This commit is contained in:
parent
344387c9c6
commit
50d7682776
5
.changeset/kind-seals-arrive.md
Normal file
5
.changeset/kind-seals-arrive.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'remotedev-redux-devtools-extension': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix DevTools from losing connection
|
|
@ -29,3 +29,9 @@ chrome.storage.onChanged.addListener((changes) => {
|
||||||
else removeMenu();
|
else removeMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://developer.chrome.com/docs/extensions/develop/migrate/to-service-workers#keep_a_service_worker_alive_continuously
|
||||||
|
setInterval(
|
||||||
|
() => chrome.storage.local.set({ 'last-heartbeat': new Date().getTime() }),
|
||||||
|
20000,
|
||||||
|
);
|
||||||
|
|
|
@ -553,8 +553,7 @@ function onConnect<S, A extends Action<string>>(port: chrome.runtime.Port) {
|
||||||
console.log(`Connected to tab ${id}`);
|
console.log(`Connected to tab ${id}`);
|
||||||
if (port.sender!.frameId) id = `${id}-${port.sender!.frameId}`;
|
if (port.sender!.frameId) id = `${id}-${port.sender!.frameId}`;
|
||||||
connections.tab[id] = port;
|
connections.tab[id] = port;
|
||||||
listener = (msg: ContentScriptToBackgroundMessage<S, A> | 'heartbeat') => {
|
listener = (msg: ContentScriptToBackgroundMessage<S, A>) => {
|
||||||
if (msg === 'heartbeat') return;
|
|
||||||
console.log(`Message from tab ${id}: ${msg.name}`);
|
console.log(`Message from tab ${id}: ${msg.name}`);
|
||||||
if (msg.name === 'INIT_INSTANCE') {
|
if (msg.name === 'INIT_INSTANCE') {
|
||||||
if (typeof id === 'number') {
|
if (typeof id === 'number') {
|
||||||
|
@ -593,8 +592,7 @@ function onConnect<S, A extends Action<string>>(port: chrome.runtime.Port) {
|
||||||
connections.panel[id] = port;
|
connections.panel[id] = port;
|
||||||
monitors++;
|
monitors++;
|
||||||
toAllTabs({ type: 'START' });
|
toAllTabs({ type: 'START' });
|
||||||
listener = (msg: BackgroundAction | 'heartbeat') => {
|
listener = (msg: BackgroundAction) => {
|
||||||
if (msg === 'heartbeat') return;
|
|
||||||
console.log(`Message from monitor ${id}: ${msg.type}`);
|
console.log(`Message from monitor ${id}: ${msg.type}`);
|
||||||
store.dispatch(msg);
|
store.dispatch(msg);
|
||||||
};
|
};
|
||||||
|
|
|
@ -343,7 +343,3 @@ function handleMessages<S, A extends Action<string>>(
|
||||||
prefetchOptions();
|
prefetchOptions();
|
||||||
|
|
||||||
window.addEventListener('message', handleMessages, false);
|
window.addEventListener('message', handleMessages, false);
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
bg?.postMessage('heartbeat');
|
|
||||||
}, 15000);
|
|
||||||
|
|
|
@ -116,10 +116,6 @@ function init() {
|
||||||
}
|
}
|
||||||
bgConnection = chrome.runtime.connect({ name });
|
bgConnection = chrome.runtime.connect({ name });
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
bgConnection.postMessage('heartbeat');
|
|
||||||
}, 15000);
|
|
||||||
|
|
||||||
bgConnection.onMessage.addListener(
|
bgConnection.onMessage.addListener(
|
||||||
<S, A extends Action<string>>(
|
<S, A extends Action<string>>(
|
||||||
message: PanelMessageWithSplitAction<S, A>,
|
message: PanelMessageWithSplitAction<S, A>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user