Skip to content

Releases: moleculerjs/moleculer

v0.14.26

10 Nov 08:38
Compare
Choose a tag to compare

What's Changed

Changes

  • fix typescript definitions for the Service class #1139
  • allow matching hooks to multiple actions with "|" #1149
  • fix serializers datetime flaky test #1151

New Contributors

Full Changelog: v0.14.25...v0.14.26

v0.14.25

29 Oct 17:10
Compare
Choose a tag to compare

Changes

  • fix Node 19 compatibility

Full Changelog: v0.14.24...v0.14.25

v0.14.24

11 Oct 07:05
Compare
Choose a tag to compare

Changes

  • allow moleculer-runner to resolve configuration files from node_modules #1126
  • fixed slower broker startup time issue #1132
  • fixed memory leak at dynamic service creation #1121
  • fixed invalid 'undefined' type in validator schema. #1137
  • update dependencies

v0.14.23

16 Aug 14:01
Compare
Choose a tag to compare

Changes

  • fixed timeout issue in waitForServices method #1123
  • fixed metadata issue when compression enabled #1122

v0.14.22

13 Aug 16:18
Compare
Choose a tag to compare

35 commits from 11 contributors.

Changes

  • fixed 'Ctx is undefined when using shard strategy and preferLocal is false, throws error on emit' #1072
  • fixed info packet send at broker stop #1101
  • added support for either-or versions to waitForServices #1030
  • fixed streaming issue with compression #1100
  • add requestID to debug logs in transit #1104
  • removed static on methods for the use of ServiceFactory #1098
  • fixed the issue with setting tracing and metrics options with env variables #1112
  • added dependencyTimeout broker option #1118
  • improved d.ts #1099 #1111 #1115
  • updated dependencies

v0.14.21

30 Apr 11:03
Compare
Choose a tag to compare

20 commits from 2 contributors.

ESM support #1063

This version contains an ESM-based Moleculer Runner. This Runner is able to load ESM configuration file and ESM services. It can load the CJS services, as well

Example usage

moleculer-runner-esm --repl services/**/*.service.mjs

Moreover, the index.js file is wrapped into index.mjs, so you can import internal modules from the core in ESM modules. E.g.:

import { ServiceBroker, Errors } from "moleculer";

Please note, the hot-reload function doesn't work with this ESM Runner. The cause: https://github.com/nodejs/modules/issues/307
Node maintainers try to solve the missing features (module cache and module dependency tree) with loaders but this API is not stable yet.

Other Changes

  • broker.stopping property is created to indicate that broker is in stopping state.

v0.14.20

19 Apr 18:01
Compare
Choose a tag to compare

52 commits from 8 contributors.

Dependency logic changed #1077

In mixed architecture, it's not hard to create a circular service dependency that may cause a dead-lock during the start of Moleculer nodes. The problem is that Moleculer node only sends the local service registry to remote nodes after all local services started properly.
As of 0.14.20, this behavior has changed. The new logic uses a debounced registry sending method which is triggered every time a local service, that the node manages, has started().
Note that the new method generates more INFO packets, than early versions, during the start of the node. The number of INFO packets depends on the number of the services that the node manages. The debounce timeout, between sending INFO packets, is 1 second.

Other Changes

  • fix ActionLogger and TransitLogger middlewares.
  • update Datadog Logger using v2 API. #1056
  • update dependencies.
  • update d.ts file. #1064, #1073
  • fix pino child logger bindings. #1075

v0.14.19

08 Jan 17:11
Compare
Choose a tag to compare

69 commits from 7 contributors.

Custom error recreation feature #1017

You can create a custom Regenerator class which is able to serialize and deserialize your custom errors. It's necessary when the custom error is created on a remote node and must be serialized to be able to sent back to the caller.

Create a custom Regenerator

const { Regenerator, MoleculerError } = require("moleculer").Errors;

class TimestampedError extends MoleculerError {
    constructor(message, code, type, data, timestamp) {
        super(message, code, type, data);
        this.timestamp = timestamp;
    }
}

class CustomRegenerator extends Regenerator {
    restoreCustomError(plainError, payload) {
        const { name, message, code, type, data, timestamp } = plainError;
        switch (name) {
            case "TimestampedError":
                return new TimestampedError(message, code, type, data, timestamp);
        }
    }
    extractPlainError(err) {
        return {
            ...super.extractPlainError(err),
            timestamp: err.timestamp
        };
    }
}
module.exports = CustomRegenerator;

Use it in broker options

// moleculer.config.js
const CustomRegenerator = require("./custom-regenerator");
module.exports = {
    errorRegenerator: new CustomRegenerator()
}

Error events #1048

When an error occured inside ServiceBroker, it's printed to the console, but there was no option that you can process it programatically (e.g. transfer to an external monitoring service). This feature solves it. Every error inside ServiceBroker broadcasts a local (not transported) event ($transporter.error, $broker.error, $transit.error, $cacher.error, $discoverer.error) what you can listen in your dedicated service or in a middleware.

Example to listen in an error-tracker service

module.exports = {
    name: "error-tracker",

    events: {
        "$**.error": {
            handler(ctx) {
                // Send the error to the tracker
                this.sendError(ctx.params.error);
            }
        }
    }
}

Example to listen in a middleware or in broker options

module.exports = {
    created(broker) {
        broker.localBus.on("*.error", payload => {
            // Send the error to the tracker
            this.sendError(payload.error);
        });
    }
}

Wildcards in Action Hooks #1051

You can use * wildcard in action names when you use it in Action Hooks.

Example

hooks: {
    before: {
        // Applies to all actions that start with "create-"
        "create-*": [],
        
        // Applies to all actions that end with "-user"
        "*-user": [],
    }
}

Other Changes

  • update dependencies.
  • update d.ts file. #1025, #1028, #1032
  • add safetyTags option to tracing exporters. #1052

v0.14.18

20 Oct 18:50
Compare
Choose a tag to compare

20 commits from 7 contributors.

Changes

  • update dependencies.
  • expose Cacher and Validator middlewares. #1012
  • update d.ts file. #1013
  • parse user & password from NATS server urls. #1021

v0.14.17

13 Sep 16:18
Compare
Choose a tag to compare

61 commits from 10 contributors.

Changes

  • reformat codebase with Prettier.
  • fix binding issue in Pino logger. #974
  • update d.ts file. #980 #970
  • transit message handler promises are resolved. #984
  • fix cacher issue if cacher is not connected. #987
  • fix Jest open handlers issue. #989
  • fix cacher cloning issue. #990
  • add custom headers option to Zipkin trace exporter. #993
  • fix heartbeatTimeout option in BaseDiscoverer. #985
  • add cacher keygen option action definition. #1004
  • update dependencies