Missing error handling #1

Closed
opened 2019-01-14 20:27:44 +00:00 by Ghost · 2 comments

There is one code path where getCertificatesAsync is executed without any error handler: https://git.coolaj86.com/coolaj86/le-sni-auto.js/src/branch/master/index.js#L141

If the promise is rejected for any reason the node process crashes due to UnhandledRejectionError: Unhandled rejection.

There is one code path where getCertificatesAsync is executed without any error handler: https://git.coolaj86.com/coolaj86/le-sni-auto.js/src/branch/master/index.js#L141 If the promise is rejected for any reason the node process crashes due to `UnhandledRejectionError: Unhandled rejection`.
Author

This is causing a bit of headache of mine as the error crashes the server once I changed the renewalBy value

Error: [ERROR] Certificate issued at '2018-11-20T02:13:58.000Z' and expires at '2019-02-18T02:13:58.000Z'. Ignoring renewal attempt until '2019-02-04T02:13:58.000Z'. Set { duplicate: true } to force. (Most recent call first)
at Object.renewAsync (/opt/node-v10.15/lib/node_modules/michaelhost/node_modules/greenlock/lib/core.js line 341 col 17)
338        log(args.debug, "(Renew) Renewable At", new Date(renewableAt).toISOString());
339
340        if (!args.duplicate && Date.now() < renewableAt) {
341          err = new Error(
342              "[ERROR] Certificate issued at '"
343            + new Date(certs.issuedAt).toISOString() + "' and expires at '"
344            + new Date(certs.expiresAt).toISOString() + "'. Ignoring renewal attempt until '"
at <unknown> (/opt/node-v10.15/lib/node_modules/michaelhost/node_modules/greenlock/index.js line 451 col 43)
448
449            if (results.certs) {
450              log(gl.debug, 'gl renewing');
451              return gl.core.certificates.renewAsync(results.options, results.certs).then(
452                function (certs) {
453                  // Workaround for https://github.com/nodejs/node/issues/22389
454                  gl._updateServernames(certs);
at Promise.resolve.then.then.result (/opt/node-v10.15/lib/node_modules/michaelhost/lib/initGreenlock.js line 24 col 25)
21
22          return { options, certs };
23        })
24        .then(result => cb(null, result), error => cb(error)),
25  });
26
27  return greenlock;
This is causing a bit of headache of mine as the error crashes the server once I changed the renewalBy value ``` Error: [ERROR] Certificate issued at '2018-11-20T02:13:58.000Z' and expires at '2019-02-18T02:13:58.000Z'. Ignoring renewal attempt until '2019-02-04T02:13:58.000Z'. Set { duplicate: true } to force. (Most recent call first) at Object.renewAsync (/opt/node-v10.15/lib/node_modules/michaelhost/node_modules/greenlock/lib/core.js line 341 col 17) 338 log(args.debug, "(Renew) Renewable At", new Date(renewableAt).toISOString()); 339 340 if (!args.duplicate && Date.now() < renewableAt) { 341 err = new Error( 342 "[ERROR] Certificate issued at '" 343 + new Date(certs.issuedAt).toISOString() + "' and expires at '" 344 + new Date(certs.expiresAt).toISOString() + "'. Ignoring renewal attempt until '" at <unknown> (/opt/node-v10.15/lib/node_modules/michaelhost/node_modules/greenlock/index.js line 451 col 43) 448 449 if (results.certs) { 450 log(gl.debug, 'gl renewing'); 451 return gl.core.certificates.renewAsync(results.options, results.certs).then( 452 function (certs) { 453 // Workaround for https://github.com/nodejs/node/issues/22389 454 gl._updateServernames(certs); at Promise.resolve.then.then.result (/opt/node-v10.15/lib/node_modules/michaelhost/lib/initGreenlock.js line 24 col 25) 21 22 return { options, certs }; 23 }) 24 .then(result => cb(null, result), error => cb(error)), 25 }); 26 27 return greenlock; ```
Owner

Published le-sni-auto@2.1.9

Many thanks to @layerssss for the fix. Sorry for the long delay.

Published le-sni-auto@2.1.9 Many thanks to @layerssss for the fix. Sorry for the long delay.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coolaj86/le-sni-auto.js#1
No description provided.