@wolfstar/plugin-sharder 0.2.0 → 0.2.1-next-20261006111920
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/esm/index.js +17 -12
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="https://cdn.wolfstar.rocks/
|
|
4
|
-
|
|
5
|
-
# @wolfstar/plugin-sharder
|
|
3
|
+
<h1><a href="https://wolfstar.rocks"><img src="https://cdn.wolfstar.rocks/logos/plugins/plugin-sharder.svg" width="40" height="40" alt="WolfStar" align="top"></a> @wolfstar/plugin-sharder</h1>
|
|
6
4
|
|
|
7
5
|
**Multi-process and multi-machine sharding for `@wolfstar/plugin-gateway`, or any bot.**
|
|
8
6
|
|
package/dist/esm/index.js
CHANGED
|
@@ -269,7 +269,7 @@ var ShardSpawnError = class extends Error {
|
|
|
269
269
|
*/
|
|
270
270
|
code;
|
|
271
271
|
constructor(channelId, code, cause) {
|
|
272
|
-
super(cause
|
|
272
|
+
super(cause === void 0 ? `Shard ${channelId} exited with code ${code} before it was ready` : `Shard ${channelId} failed to start: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
273
273
|
this.name = "ShardSpawnError";
|
|
274
274
|
this.channelId = channelId;
|
|
275
275
|
this.code = code;
|
|
@@ -750,11 +750,17 @@ var ShardChannel = class extends EventEmitter {
|
|
|
750
750
|
messageHandler: this.manager.codec.handler.name,
|
|
751
751
|
transformers: this.manager.codec.transformers.map((transformer) => transformer.name)
|
|
752
752
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
753
|
+
try {
|
|
754
|
+
instance.transport = this.manager.strategy.spawn(context, {
|
|
755
|
+
message: (data) => void this.#receive(instance, data),
|
|
756
|
+
exit: (code) => this.#exited(instance, code),
|
|
757
|
+
error: (error) => this.#failed(instance, error)
|
|
758
|
+
}, { env: this.manager.spawnEnv });
|
|
759
|
+
} catch (error) {
|
|
760
|
+
const spawnError = new ShardSpawnError(this.id, null, error);
|
|
761
|
+
this.manager.reportShardError(this, spawnError);
|
|
762
|
+
throw spawnError;
|
|
763
|
+
}
|
|
758
764
|
const estimate = this.manager.readyEstimate;
|
|
759
765
|
if (estimate !== null) {
|
|
760
766
|
instance.slowStart = setTimeout(() => {
|
|
@@ -1508,12 +1514,11 @@ var ClusterStrategy = class extends ProcessStrategy {
|
|
|
1508
1514
|
}
|
|
1509
1515
|
createProcess(context, options) {
|
|
1510
1516
|
const { path, args, execArgv, env } = this.options;
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
});
|
|
1517
|
+
const settings = { serialization: "advanced" };
|
|
1518
|
+
if (path) settings.exec = path instanceof URL ? fileURLToPath(path) : path;
|
|
1519
|
+
if (args) settings.args = [...args];
|
|
1520
|
+
if (execArgv) settings.execArgv = [...execArgv];
|
|
1521
|
+
cluster.setupPrimary(settings);
|
|
1517
1522
|
return cluster.fork({
|
|
1518
1523
|
...env,
|
|
1519
1524
|
...options.env,
|