Apostrophe CMS Main Site Forum Home

Apostrophe 2.89.0: significant reliability and logging improvements


#1
  • Many significant improvements to make crashes and restarts less likely.
  • The most frequently used methods now sanity-check their arguments and invoke their callback, or as appropriate, if they are not valid. This replaces many full-process crashes with polite 500 errors.
  • New, safer and easier alternatives to self.route:
    • self.apiRoute, which accepts a next function that can be passed either an error, or (null, value), where value is an object to be sent to the browser with a status: 'ok' property automatically added — the convention for APIs in Apostrophe 2.x. In addition, errors reported to next are converted to status properties and/or logged gracefully, including more complete information about where the error took place for easier debugging. Most core routes have been refactored to use it. This approach extends Express 4.0’s concept of error handlers with the ability to handle success as well. You can still use res if you need to, for instance to issue a redirect.
    • self.renderRoute, which accepts a next function that can be passed either an error that will be mapped to an appropriate HTTP status code, or (null, { template: 'templateName', data: { ... props for the template ... }). The named template is rendered with self.render, and any exceptions thrown are caught properly and logged as errors without a process crash — unlike what frequently happened before in such routes.
    • self.htmlRoute, similar to renderRoute but it does not render the markup for you; instead you pass markup as the second argument to next(). Useful if you are rendering by some means other than self.render.
  • For template errors, a great deal of redundant error logging has been removed.
  • Introduced apos.utils.warnDevOnce, refactored some existing warnings to use it, and added a call for CSRF errors to help developers understand what these mean.
  • New trace feature to help debug crashes in Apostrophe’s startup process. Try: APOS_TRACE_STARTUP=1 node app

Thanks to Michelin for making this work possible via Apostrophe Enterprise Support. Your organization can also take advantage of the opportunity to fund development of the features you would like to see as well as receiving fast, personal support from Apostrophe’s core development team.