Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: merge staging to master #850

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polykey",
"version": "1.16.1",
"version": "1.16.2",
"homepage": "https://polykey.com",
"author": "Matrix AI",
"contributors": [
Expand Down
27 changes: 18 additions & 9 deletions src/nodes/NodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ class NodeManager {
this.syncNodeGraphHandlerId,
this.syncNodeGraphHandler,
);
// This will clean up tasks that were not properly cleaned up during an ungracefully shutdown of the process
await this.stopTasks();
await this.setupRefreshBucketTasks();
// Can be disabled with 0 delay, only use for testing
if (this.retryConnectionsDelayTime > 0) {
Expand Down Expand Up @@ -445,15 +447,7 @@ class NodeManager {
this.handleEventNodeConnectionManagerConnection,
);
await this.mdns?.stop();
// Cancels all NodeManager tasks
const taskPs: Array<Promise<any>> = [];
for await (const task of this.taskManager.getTasks(undefined, false, [
this.tasksPath,
])) {
taskPs.push(task.promise());
task.cancel(abortEphemeralTaskReason);
}
await Promise.allSettled(taskPs);
await this.stopTasks();
this.taskManager.deregisterHandler(this.refreshBucketHandlerId);
this.taskManager.deregisterHandler(this.gcBucketHandlerId);
this.taskManager.deregisterHandler(this.checkConnectionsHandlerId);
Expand Down Expand Up @@ -2089,6 +2083,21 @@ class NodeManager {
this.logger.info('Set up refreshBucket tasks');
}

/**
* Cancels all NodeManager tasks.
* These are ephemeral and will be recreated next time we start.
*/
protected async stopTasks() {
const taskPs: Array<Promise<any>> = [];
for await (const task of this.taskManager.getTasks(undefined, false, [
this.tasksPath,
])) {
taskPs.push(task.promise());
task.cancel(abortEphemeralTaskReason);
}
await Promise.allSettled(taskPs);
}

@ready(new nodesErrors.ErrorNodeManagerNotRunning(), true, ['stopping'])
public async updateRefreshBucketDelay(
bucketIndex: number,
Expand Down
Loading