Adding core exceptions; Pusher timeouts and sourcemaps to production

This commit is contained in:
James Barnsley
2017-10-01 09:38:01 +13:00
parent 306d94e4c5
commit 0d28d9910e
6 changed files with 119 additions and 35 deletions

View File

@ -79,7 +79,11 @@ class IrisCore(object):
def send_message(self, to, data):
try:
self.connections[to]['connection'].write_message( json_encode(data) )
except:
self.raven_client.captureException()
logger.error('Failed to send message to '+ to)
def broadcast(self, data):

View File

@ -43,7 +43,7 @@
"scripts": {
"build": "./build.sh",
"dev": "./build.sh && NODE_ENV=development webpack --watch",
"prod": "./build.sh && NODE_ENV=development webpack && NODE_ENV=production webpack",
"prod": "./build.sh && NODE_ENV=development webpack && NODE_ENV=production webpack --watch",
"release": "./build.sh && NODE_ENV=production webpack && NODE_ENV=development webpack && python setup.py sdist upload -r pypi && ./release.sh"
}
}

View File

@ -59,10 +59,12 @@ const CoreMiddleware = (function(){
}
);
if (action.data.xhr){
var xhr_response = JSON.parse(action.data.xhr.responseText);
if (xhr_response.error && xhr_response.error.message){
message = message+'<p class="description">'+xhr_response.error.message+'</p>';
}
}
store.dispatch(uiActions.createNotification(message,'bad'));
console.error(action.message, data);

View File

@ -52,6 +52,7 @@ const PusherMiddleware = (function(){
const request = (store, method, data = {}) => {
return new Promise( (resolve, reject) => {
var request_id = helpers.generateGuid()
var message = {
method: method,
@ -62,6 +63,15 @@ const PusherMiddleware = (function(){
store.dispatch(uiActions.startLoading(request_id, 'pusher_'+method))
// Start our 10 second timeout
var timeout = setTimeout(
function(){
store.dispatch(uiActions.stopLoading(request_id));
reject({message: "Request timed out", method: method, data: data});
},
10000
);
// add query to our deferred responses
deferredRequests[request_id] = {
resolve: resolve,
@ -130,6 +140,12 @@ const PusherMiddleware = (function(){
locale: response.config.locale
}))
}
},
error => {
store.dispatch(coreActions.handleException(
'Could not load config',
error
));
}
)
request(store, 'get_version')
@ -141,6 +157,12 @@ const PusherMiddleware = (function(){
}
response.type = 'PUSHER_VERSION'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not load version',
error
));
}
)
request(store, 'get_radio')
@ -153,6 +175,12 @@ const PusherMiddleware = (function(){
response.type = 'PUSHER_RADIO'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not load radio',
error
));
}
)
@ -166,6 +194,12 @@ const PusherMiddleware = (function(){
.then(
response => {
store.dispatch({ type: 'PUSHER_INSTRUCT', data: response.data })
},
error => {
store.dispatch(coreActions.handleException(
'Instruct failed',
error
));
}
)
break
@ -175,6 +209,12 @@ const PusherMiddleware = (function(){
.then(
response => {
store.dispatch( uiActions.createNotification('Message delivered') )
},
error => {
store.dispatch(coreActions.handleException(
'Could not deliver message',
error
));
}
)
break
@ -189,6 +229,12 @@ const PusherMiddleware = (function(){
response => {
response.type = 'PUSHER_QUEUE_METADATA'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not load queue metadata',
error
));
}
)
break;
@ -219,6 +265,12 @@ const PusherMiddleware = (function(){
response.type = 'PUSHER_VERSION'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not start upgrade',
error
));
}
)
return next(action);
@ -236,6 +288,12 @@ const PusherMiddleware = (function(){
}
response.type = 'PUSHER_USERNAME_CHANGED'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not set username',
error
));
}
)
return next(action);
@ -251,6 +309,12 @@ const PusherMiddleware = (function(){
}
response.type = 'PUSHER_CONNECTIONS'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not load connections',
error
));
}
)
return next(action);
@ -293,12 +357,20 @@ const PusherMiddleware = (function(){
}
request(store, 'change_radio', data)
.then(response => {
.then(
response => {
if (response.status == 0){
store.dispatch(uiActions.createNotification(response.message, 'bad'))
}
store.dispatch(uiActions.processFinished('PUSHER_RADIO_PROCESS'))
})
},
error => {
store.dispatch(coreActions.handleException(
'Could not change radio',
error
));
}
)
break
case 'PUSHER_STOP_RADIO':
@ -357,6 +429,12 @@ const PusherMiddleware = (function(){
.then(
response => {
store.dispatch({type: 'DEBUG', response: response})
},
error => {
store.dispatch(coreActions.handleException(
'Could not debug',
error
));
}
)
break;

View File

@ -27,7 +27,7 @@ class Album extends React.Component{
}
componentDidMount(){
this.loadAlbum()
this.loadAlbum();
}
handleContextMenu(e){

View File

@ -122,13 +122,13 @@ if (isDev){
// set compiled css location
config.plugins.push( new ExtractTextPlugin("app.min.css") );
// uglify our js, with no sourcemaps
// uglify our js
config.devtool = 'sourcemap';
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: true,
mangle: false,
sourceMap: false,
comments: false
sourceMap: true
})
);
}