@lodestar/beacon-node 1.46.0-dev.3d8f7cf440 → 1.46.0-dev.3e8651f2dc
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/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +1 -1
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +11 -3
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/chain.d.ts +5 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +55 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +6 -0
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +5 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/options.d.ts +2 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.d.ts +8 -3
- package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockProposers.js +25 -11
- package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +8 -5
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +1 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +4 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/networkCore.d.ts.map +1 -1
- package/lib/network/core/networkCore.js +12 -1
- package/lib/network/core/networkCore.js.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
- package/lib/network/core/networkCoreWorkerHandler.js +20 -3
- package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +11 -1
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +8 -0
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/util/workerEvents.d.ts +7 -1
- package/lib/util/workerEvents.d.ts.map +1 -1
- package/lib/util/workerEvents.js +17 -5
- package/lib/util/workerEvents.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +6 -1
- package/src/chain/blocks/verifyBlock.ts +16 -6
- package/src/chain/chain.ts +60 -0
- package/src/chain/emitter.ts +7 -0
- package/src/chain/interface.ts +3 -0
- package/src/chain/options.ts +3 -0
- package/src/chain/produceBlock/produceBlockBody.ts +1 -1
- package/src/chain/seenCache/seenBlockProposers.ts +40 -14
- package/src/chain/validation/block.ts +8 -4
- package/src/metrics/metrics/lodestar.ts +4 -0
- package/src/network/core/networkCore.ts +13 -1
- package/src/network/core/networkCoreWorkerHandler.ts +18 -3
- package/src/network/network.ts +16 -1
- package/src/network/processor/gossipHandlers.ts +7 -0
- package/src/util/workerEvents.ts +18 -6
package/src/util/workerEvents.ts
CHANGED
|
@@ -111,6 +111,12 @@ export function wireEventsOnMainThread<EventData>(
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Terminate a worker thread, bounded to `retryCount * retryMs`.
|
|
116
|
+
*
|
|
117
|
+
* @returns `false` if it could not be terminated, the worker thread is then still running and the
|
|
118
|
+
* caller has to decide how to proceed without it.
|
|
119
|
+
*/
|
|
114
120
|
export async function terminateWorkerThread({
|
|
115
121
|
worker,
|
|
116
122
|
retryMs,
|
|
@@ -121,7 +127,7 @@ export async function terminateWorkerThread({
|
|
|
121
127
|
retryMs: number;
|
|
122
128
|
retryCount: number;
|
|
123
129
|
logger?: Logger;
|
|
124
|
-
}): Promise<
|
|
130
|
+
}): Promise<boolean> {
|
|
125
131
|
const terminated = new Promise((resolve) => {
|
|
126
132
|
Thread.events(worker).subscribe((event) => {
|
|
127
133
|
if (event.type === "termination") {
|
|
@@ -131,13 +137,19 @@ export async function terminateWorkerThread({
|
|
|
131
137
|
});
|
|
132
138
|
|
|
133
139
|
for (let i = 0; i < retryCount; i++) {
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
// `Worker.terminate()` resolves only once the worker thread exits, and the thread can spin
|
|
141
|
+
// forever in `Environment::CleanupHandles()` when a libuv handle on its loop never closes, so
|
|
142
|
+
// it has to be raced too, otherwise `retryCount * retryMs` never applies.
|
|
143
|
+
const result = await Promise.race([
|
|
144
|
+
Thread.terminate(worker).then(() => terminated),
|
|
145
|
+
sleep(retryMs).then(() => false),
|
|
146
|
+
]);
|
|
136
147
|
|
|
137
|
-
if (result) return;
|
|
148
|
+
if (result) return true;
|
|
138
149
|
|
|
139
|
-
logger?.
|
|
150
|
+
logger?.debug("Worker thread failed to terminate, retrying...");
|
|
140
151
|
}
|
|
141
152
|
|
|
142
|
-
|
|
153
|
+
logger?.debug(`Worker thread failed to terminate in ${retryCount * retryMs}ms`);
|
|
154
|
+
return false;
|
|
143
155
|
}
|