Releases: moleculerjs/moleculer
v0.14.26
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
- @sabadoryo made their first contribution in #1148
- @SKarajic made their first contribution in #1139
- @someone635 made their first contribution in #1149
- @sorattorafa made their first contribution in #1151
Full Changelog: v0.14.25...v0.14.26
v0.14.25
v0.14.24
v0.14.23
v0.14.22
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
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
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
v0.14.19
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
v0.14.18
v0.14.17
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