Skip to content

Commit

Permalink
Do not add online event if we have no window
Browse files Browse the repository at this point in the history
Refs: #468
  • Loading branch information
tshemsedinov committed Nov 15, 2023
1 parent 453c508 commit 864fa5a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dist/metacom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ const RECONNECT_TIMEOUT = 2 * 1000;

const connections = new Set();

window.addEventListener('online', () => {
for (const connection of connections) {
if (!connection.connected) connection.open();
}
});
if (window) {
window.addEventListener('online', () => {
for (const connection of connections) {
if (!connection.connected) connection.open();
}
});
}

class MetacomError extends Error {
constructor({ message, code }) {
Expand Down

0 comments on commit 864fa5a

Please sign in to comment.