Commit 994745ab authored by Eric Eastwood's avatar Eric Eastwood
Browse files

Friendly iOS notification missing config errors

After:

```
2017-07-20T22:46:07.891Z - warn: ios push notification gateway (Prod) missing config, apn:certProd:undefined apn:keyProd:undefined
{ category: 'push-notifications' }
2017-07-20T22:46:07.899Z - warn: ios push notification gateway (Dev) missing config, apn:certDev:undefined apn:keyDev:undefined
{ category: 'push-notifications' }
2017-07-20T22:46:08.011Z - warn: ios push notification feedback (Dev) missing config, apn:certDev:undefined apn:keyDev:undefined
{ category: 'push-notifications' }
```

Before:

```
2017-07-20T22:49:45.780Z - error: ios push notification feedback (Dev) experienced an error
{ error: 'ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
  category: 'push-notifications' }
2017-07-20T22:49:45.790Z - error: No error reporting is enabled so just logging to logger:
{ exception:
   { message: 'ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
     stack: 'Error: ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'\n    at Error (native)\nFrom previous event:\n
at resolveCredential (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\credentials\\resolve.js:17:31)\n    at loadCredentials (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\credentials\\load.js:14:20)\n    at Feedback.loadCredentials (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:121:29)\n    at Feedback.createSocket (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:151:7)\n    at Feedback.request (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:278:7)\n    at Feedback.start (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:270:7)\n    at new Feedback (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:88:7)\n    at createFeedbackEmitterForEnv (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:120:20)\n    at Object.createFeedbackEmitter (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:163:14)\n    at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/apn-feedback-listener.js:14:36)\n    at C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:23:21\n    at Array.forEach (native)\n
   at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:22:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\server\\web.js:26:30)\n    at require (internal/module.js:20:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\web.js:7:1)\n    at run (bootstrap_node.js:352:7)\n    at startup (bootstrap_node.js:144:9)\n    at bootstrap_node.js:467:3',
     name: 'Error' },
  meta:
   { errorString: 'Error: ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
     apnEnv: 'Dev' },
  tags:
   { host: 'some-pc',
     module: 'ios-notification-gateway',
     job: 'web' } }
2017-07-20T22:49:45.794Z - error: ios push notification feedback (Dev) experienced a feedbackError
{ error: 'ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
  category: 'push-notifications' }
2017-07-20T22:49:45.795Z - error: No error reporting is enabled so just logging to logger:
{ exception:
   { message: 'ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
     stack: 'Error: ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'\n    at Error (native)\nFrom previous event:\n
at resolveCredential (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\credentials\\resolve.js:17:31)\n    at loadCredentials (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\credentials\\load.js:14:20)\n    at Feedback.loadCredentials (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:121:29)\n    at Feedback.createSocket (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:151:7)\n    at Feedback.request (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:278:7)\n    at Feedback.start (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:270:7)\n    at new Feedback (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:88:7)\n    at createFeedbackEmitterForEnv (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:120:20)\n    at Object.createFeedbackEmitter (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:163:14)\n    at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/apn-feedback-listener.js:14:36)\n    at C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:23:21\n    at Array.forEach (native)\n
   at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:22:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\server\\web.js:26:30)\n    at require (internal/module.js:20:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\web.js:7:1)\n    at run (bootstrap_node.js:352:7)\n    at startup (bootstrap_node.js:144:9)\n    at bootstrap_node.js:467:3\nFrom previous event:\n    at Feedback.createSocket (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:150:30)\n    at Feedback.request (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:278:7)\n    at Feedback.start (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:270:7)\n    at new Feedback (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\node_modules\\apn\\lib\\feedback.js:88:7)\n    at createFeedbackEmitterForEnv (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:120:20)\n    at Object.createFeedbackEmitter (C:/Users/some-user/Documents/GitLab/webapp/modules/push-gateways/lib/ios/ios-notification-gateway.js:163:14)\n    at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/apn-feedback-listener.js:14:36)\n    at C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:23:21\n    at Array.forEach (native)\n    at Object.exports.install (C:/Users/some-user/Documents/GitLab/webapp/server/event-listeners/index.js:22:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\server\\web.js:26:30)\n    at require (internal/module.js:20:19)\n    at Object.<anonymous> (C:\\Users\\some-user\\Documents\\GitLab\\webapp\\web.js:7:1)\n    at run (bootstrap_node.js:352:7)\n    at startup (bootstrap_node.js:144:9)\n    at bootstrap_node.js:467:3',
     name: 'Error' },
  meta:
   { errorString: 'Error: ENOENT: no such file or directory, open \'C:\\Users\\some-user\\Documents\\GitLab\\webapp\\cert.pem\'',
     apnEnv: 'Dev' },
  tags:
   { host: 'some-pc',
     module: 'ios-notification-gateway',
     job: 'web' } }
```
parent 502bcb83
Pipeline #10710177 passed with stages
in 12 minutes and 5 seconds
......@@ -47,7 +47,12 @@ function sendNotificationToDevice(notificationType, notificationDetails, device)
var connection = connections[device.deviceType];
if (!connection) return Promise.reject(new Error('unknown device type: ' + device.deviceType));
if (connection === false) {
return false;
}
else if (!connection) {
return Promise.reject(new Error('unknown device type: ' + device.deviceType));
}
connection.pushNotification(appleNotification, deviceToken);
......@@ -61,9 +66,19 @@ function sendNotificationToDevice(notificationType, notificationDetails, device)
function createConnection(suffix, isProduction) {
debug('ios push notification gateway (%s) starting', suffix);
var certConfigKey = 'apn:cert' + suffix;
var cert = resolveCertConfig(certConfigKey);
var keyConfigKey = 'apn:key' + suffix;
var key = resolveCertConfig(keyConfigKey);
if(!cert || !key) {
logger.warn('ios push notification gateway (' + suffix + ') missing config, ' + certConfigKey + ':' + cert + ' ' + keyConfigKey + ':' + key);
return false;
}
var connection = new apn.Connection({
cert: resolveCertConfig('apn:cert' + suffix),
key: resolveCertConfig('apn:key' + suffix),
cert: cert,
key: key,
production: isProduction,
connectionTimeout: 60000
});
......@@ -97,7 +112,12 @@ function sendBadgeUpdateToDevice(device, badge) {
var deviceToken = new apn.Device(device.appleToken);
var connection = connections[device.deviceType];
if (!connection) return false;
if (connection === false) {
return false;
}
else if (!connection) {
return false;
}
var note = new apn.Notification();
note.badge = badge;
......@@ -117,9 +137,19 @@ function createFeedbackEmitterForEnv(suffix, isProduction) {
try {
debug('ios push notification feedback listener (%s) starting', suffix);
var certConfigKey = 'apn:cert' + suffix;
var cert = resolveCertConfig(certConfigKey);
var keyConfigKey = 'apn:key' + suffix;
var key = resolveCertConfig(keyConfigKey);
if(!cert || !key) {
logger.warn('ios push notification feedback (' + suffix + ') missing config, ' + certConfigKey + ':' + cert + ' ' + keyConfigKey + ':' + key);
return emitter;
}
var feedback = new apn.Feedback({
cert: resolveCertConfig('apn:cert' + suffix),
key: resolveCertConfig('apn:key' + suffix),
cert: cert,
key: key,
interval: config.get('apn:feedbackInterval'),
batchFeedback: true,
production: isProduction
......@@ -143,9 +173,9 @@ function createFeedbackEmitterForEnv(suffix, isProduction) {
errorReporter(err, { apnEnv: suffix }, { module: 'ios-notification-gateway' });
});
} catch(e) {
logger.error('Unable to start feedback service (' + suffix + ')', { exception: e });
errorReporter(e, { apnEnv: suffix }, { module: 'ios-notification-gateway' });
} catch(err) {
logger.error('Unable to start feedback service (' + suffix + ')', { exception: err });
errorReporter(err, { apnEnv: suffix }, { module: 'ios-notification-gateway' });
}
return emitter;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment