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):
self.connections[to]['connection'].write_message( json_encode(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,9 +59,11 @@ const CoreMiddleware = (function(){
}
);
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>';
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'));

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,
@ -61,6 +62,15 @@ const PusherMiddleware = (function(){
socket.send( JSON.stringify(message) )
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] = {
@ -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;
@ -204,23 +250,29 @@ const PusherMiddleware = (function(){
case 'PUSHER_START_UPGRADE':
ReactGA.event({ category: 'Pusher', action: 'Upgrade', label: '' })
request(store, 'upgrade')
.then(
response => {
if (response.error){
console.error(response.error)
return false
}
.then(
response => {
if (response.error){
console.error(response.error)
return false
}
if (response.upgrade_successful){
store.dispatch( uiActions.createNotification('Upgrade complete') )
}else{
store.dispatch( uiActions.createNotification('Upgrade failed, please upgrade manually','bad') )
}
if (response.upgrade_successful){
store.dispatch( uiActions.createNotification('Upgrade complete') )
}else{
store.dispatch( uiActions.createNotification('Upgrade failed, please upgrade manually','bad') )
}
response.type = 'PUSHER_VERSION'
store.dispatch(response)
}
)
response.type = 'PUSHER_VERSION'
store.dispatch(response)
},
error => {
store.dispatch(coreActions.handleException(
'Could not start upgrade',
error
));
}
)
return next(action);
break;
@ -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 => {
if (response.status == 0){
store.dispatch(uiActions.createNotification(response.message, 'bad'))
}
store.dispatch(uiActions.processFinished('PUSHER_RADIO_PROCESS'))
})
.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,15 +122,15 @@ 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
})
);
new webpack.optimize.UglifyJsPlugin({
compress: true,
mangle: false,
sourceMap: true
})
);
}
// now export our collated config object