Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
fix: catch Mixed Content failures that take down the app
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jul 8, 2019
1 parent facd32d commit 8d2ab6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class App extends Component {
{
enabled: true,
dialogOpen: false,
ws: null,
},
this.defaultState,
);
this.ws = null;

setInterval(() => {
this.updateTxnStats();
Expand All @@ -90,8 +90,9 @@ class App extends Component {
}, 10000);
}

getRemoteState(attr, url, mapFun, limit, transform) {
axios.get(url).then(response => {
async getRemoteState(attr, url, mapFun, limit, transform) {
try {
const response = await axios.get(url);
let newState = {};

if (limit) {
Expand All @@ -109,7 +110,9 @@ class App extends Component {
}

this.updateStateAttributes(newState);
});
} catch (err) {
console.error('getRemoteState failed:', err);
}
}

updateSpecificGlobalStateAttribute(attr, value) {
Expand Down Expand Up @@ -250,7 +253,7 @@ class App extends Component {
};

onEndpointChange() {
if (this.ws) {
if (this.ws !== null) {
this.ws.close();
this.ws = null;
}
Expand Down Expand Up @@ -285,7 +288,11 @@ class App extends Component {
}

componentDidMount() {
this.onEndpointChange();
try {
this.onEndpointChange();
} catch (err) {
console.error('onEndpointChange failed:', err);
}

if (!this.locationListener) {
const locationListener = this.handleLocationChange();
Expand Down
6 changes: 5 additions & 1 deletion src/AppV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import Footer from 'v2/components/Footer';
import theme from 'v2/theme';
import socket from 'v2/stores/socket';

socket.init();
try {
socket.init();
} catch (err) {
console.error('Socket init failed:', err);
}

const Dashboard = lazy(() => import('v2/components/Dashboard'));

Expand Down

0 comments on commit 8d2ab6f

Please sign in to comment.