Hemera v1.2.0 Release Notes

  • Summary

    ๐Ÿ”Œ hemera 1.2.0 is focused on error handling, plugin dependencies

    • โฌ†๏ธ Upgrade time: low - none to a couple of hours for most users
    • Complexity: low - requires following the list of changes to verifying their impact
    • Risk: medium - type checks on error will fail because the hemera error was stripped
    • Dependencies: low - existing plugins will work as-is

    ๐Ÿ’ฅ Breaking Changes

    ๐Ÿ”Œ You get the exact error you have sent. Errors are wrapped only for framework errors (Parsing errors, Plugin registration errors, Timeout errors) or logging.

    ๐Ÿ†• New Features

    • ๐Ÿ”ง Enable Server policy to abort requests when the server is not able to respond cause (max memory, busy event-loop). Example Configurable
    • ๐Ÿ”ง Long stack traces by default. Configurable
    • ๐Ÿ”ง Detect message loops (abort the request and return an error). Example Configurable
    • ๐Ÿ”Š Enrich errors logs with details (pattern, app-name, timestamp).
    • Track network hops in error to identify which clients was involved. Example

    Migration Checklist

    ๐Ÿ‘€ 1. Pull the wrapped error one level up. For any case except for: HemeraParseError, HemeraError "Error during plugin registration, TimeoutError"

    Old:

    hemera.add({
      topic: 'email',
      cmd: 'send'
    }, (resp, cb) => {
      cb(new Error('Uups'))
    })
    
    hemera.act({
      topic: 'email',
      cmd: 'send',
      email: '[email protected]',
      msg: 'Hi!'
    }, (err, resp) => {
      expect(err).to.be.exists()
      expect(err.name).to.be.equals('BusinessError')
      expect(err.message).to.be.equals('Business Error') 
      expect(err.cause.name).to.be.equals('Error')
      expect(err.cause.message).to.be.equals('Uups')
      hemera.close()
      done()
    })
    

    ๐Ÿ†• New:

    hemera.add({
      topic: 'email',
      cmd: 'send'
    }, (resp, cb) => {
      cb(new Error('Uups'))
    })
    
    hemera.act({
      topic: 'email',
      cmd: 'send',
      email: '[email protected]',
      msg: 'Hi!'
    }, (err, resp) => {
      expect(err).to.be.exists()
      expect(err.name).to.be.equals('Error')
      expect(err.message).to.be.equals('Uups')
      hemera.close()
      done()
    })
    

    ๐Ÿ”Š 2. All logs are wrapped with the correct Hemera error subclass BusinessError, FatalError ...

    ๐Ÿ”Œ 3. Plugin dependencies are declared with peerDependencies instead with dependencies property in the plugin.

    Old:

    exports.attributes = {
      dependencies: ['hemera-joi']
      pkg: require('./package.json')
    }
    

    ๐Ÿ†• New:

    "peerDependencies": {
      "hemera-joi": "^1.0.4",
      "nats-hemera": "1.x || 2.x"
    }