Skip to content

Commit 166226f

Browse files
committed
fix: impl actually good coderabbit nitpicks
1 parent 39f41a1 commit 166226f

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/typegate/src/runtimes/substantial/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export class Agent {
5858
this.logger = getLoggerByAddress(import.meta, "substantial");
5959
this.mustLockRunIds = new Map();
6060

61-
this.pollInterval = new BlockingInterval(this.logger);
62-
this.hearbeatInterval = new BlockingInterval(this.logger);
61+
this.pollInterval = new BlockingInterval();
62+
this.hearbeatInterval = new BlockingInterval();
6363
}
6464

6565
async schedule(input: AddScheduleInput) {

src/typegate/src/runtimes/substantial/workflow_worker_manager.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: MPL-2.0
33

44
import { globalConfig } from "../../config.ts";
5-
import { getLogger, type Logger } from "../../log.ts";
5+
import { getLogger } from "../../log.ts";
66
import type { TaskContext } from "../deno/shared_types.ts";
77
import { DenoWorker } from "../patterns/worker_manager/deno.ts";
88
import { BaseWorkerManager } from "../patterns/worker_manager/mod.ts";
@@ -118,8 +118,7 @@ export class BlockingInterval {
118118
#killed = false;
119119
#running = false;
120120

121-
constructor(private logger?: Logger) {
122-
}
121+
#runningResolver?: () => void;
123122

124123
async start(delayMs: number, handler: () => Promise<void> | void) {
125124
if (this.#running) {
@@ -130,11 +129,7 @@ export class BlockingInterval {
130129
this.#running = true;
131130

132131
while (!this.#killed) {
133-
try {
134-
await handler();
135-
} catch (err) {
136-
this.logger?.error("BlockingInterval iteration error:", err);
137-
}
132+
await handler();
138133

139134
if (this.#killed) {
140135
break;
@@ -144,22 +139,18 @@ export class BlockingInterval {
144139
}
145140

146141
this.#running = false;
142+
this.#runningResolver?.();
147143
}
148144

149145
async kill() {
150146
this.#killed = true;
151147

152148
if (this.#running) {
153-
const ensureKillMs = 60;
154-
155-
await new Promise((res) => {
156-
const interval = setInterval(() => {
157-
if (!this.#running) {
158-
clearInterval(interval);
159-
res(true);
160-
}
161-
}, ensureKillMs);
149+
await new Promise<void>((res) => {
150+
this.#runningResolver = res;
162151
});
152+
153+
this.#runningResolver = undefined;
163154
}
164155
}
165156
}

0 commit comments

Comments
 (0)