Skip to content

Commit 1afe3a7

Browse files
committed
enable strictPropertyInitialization
1 parent bbd7ea6 commit 1afe3a7

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

.configs/tsconfig.base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
"strict": true,
1212
"alwaysStrict": true,
13-
"strictPropertyInitialization": false,
13+
"strictPropertyInitialization": true,
1414
"skipLibCheck": true,
1515
"forceConsistentCasingInFileNames": true,
1616
"noUnusedLocals": false,

packages/cli-v3/src/dev/devSupervisor.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export async function startWorkerRuntime(options: WorkerRuntimeOptions): Promise
4949
* - Receiving snapshot update pings (via socket)
5050
*/
5151
class DevSupervisor implements WorkerRuntime {
52-
private config: DevConfigResponseBody;
52+
private config?: DevConfigResponseBody;
5353
private disconnectPresence: (() => void) | undefined;
5454
private lastManifest?: BuildManifest;
5555
private latestWorkerId?: string;
5656

5757
/** Receive notifications when runs change state */
58-
private socket: Socket<WorkerServerToClientEvents, WorkerClientToServerEvents>;
58+
private socket?: Socket<WorkerServerToClientEvents, WorkerClientToServerEvents>;
5959
private socketIsReconnecting = false;
6060

6161
/** Workers are versions of the code */
@@ -93,7 +93,7 @@ class DevSupervisor implements WorkerRuntime {
9393

9494
this.runLimiter = pLimit(maxConcurrentRuns);
9595

96-
this.#createSocket();
96+
this.socket = this.#createSocket();
9797

9898
//start an SSE connection for presence
9999
this.disconnectPresence = await this.#startPresenceConnection();
@@ -105,7 +105,7 @@ class DevSupervisor implements WorkerRuntime {
105105
async shutdown(): Promise<void> {
106106
this.disconnectPresence?.();
107107
try {
108-
this.socket.close();
108+
this.socket?.close();
109109
} catch (error) {
110110
logger.debug("[DevSupervisor] shutdown, socket failed to close", { error });
111111
}
@@ -187,6 +187,10 @@ class DevSupervisor implements WorkerRuntime {
187187
* For the latest version we will pull from the main queue, so we don't specify that.
188188
*/
189189
async #dequeueRuns() {
190+
if (!this.config) {
191+
throw new Error("No config, can't dequeue runs");
192+
}
193+
190194
if (!this.latestWorkerId) {
191195
//try again later
192196
logger.debug(`[DevSupervisor] dequeueRuns. No latest worker ID, trying again later`);
@@ -409,13 +413,14 @@ class DevSupervisor implements WorkerRuntime {
409413
const wsUrl = new URL(this.options.client.apiURL);
410414
wsUrl.pathname = "/dev-worker";
411415

412-
this.socket = io(wsUrl.href, {
416+
const socket = io(wsUrl.href, {
413417
transports: ["websocket"],
414418
extraHeaders: {
415419
Authorization: `Bearer ${this.options.client.accessToken}`,
416420
},
417421
});
418-
this.socket.on("run:notify", async ({ version, run }) => {
422+
423+
socket.on("run:notify", async ({ version, run }) => {
419424
logger.debug("[DevSupervisor] Received run notification", { version, run });
420425

421426
this.options.client.dev.sendDebugLog(run.friendlyId, {
@@ -434,10 +439,11 @@ class DevSupervisor implements WorkerRuntime {
434439

435440
await controller.getLatestSnapshot();
436441
});
437-
this.socket.on("connect", () => {
442+
443+
socket.on("connect", () => {
438444
logger.debug("[DevSupervisor] Connected to supervisor");
439445

440-
if (this.socket.recovered || this.socketIsReconnecting) {
446+
if (socket.recovered || this.socketIsReconnecting) {
441447
logger.debug("[DevSupervisor] Socket recovered");
442448
eventBus.emit("socketConnectionReconnected", `Connection was recovered`);
443449
}
@@ -448,19 +454,21 @@ class DevSupervisor implements WorkerRuntime {
448454
controller.resubscribeToRunNotifications();
449455
}
450456
});
451-
this.socket.on("connect_error", (error) => {
457+
458+
socket.on("connect_error", (error) => {
452459
logger.debug("[DevSupervisor] Connection error", { error });
453460
});
454-
this.socket.on("disconnect", (reason, description) => {
461+
462+
socket.on("disconnect", (reason, description) => {
455463
logger.debug("[DevSupervisor] socket was disconnected", {
456464
reason,
457465
description,
458-
active: this.socket.active,
466+
active: socket.active,
459467
});
460468

461469
if (reason === "io server disconnect") {
462470
// the disconnection was initiated by the server, you need to manually reconnect
463-
this.socket.connect();
471+
socket.connect();
464472
} else {
465473
this.socketIsReconnecting = true;
466474
eventBus.emit("socketConnectionDisconnected", reason);
@@ -472,6 +480,8 @@ class DevSupervisor implements WorkerRuntime {
472480
connections: Array.from(this.socketConnections),
473481
});
474482
}, 5000);
483+
484+
return socket;
475485
}
476486

477487
#subscribeToRunNotifications() {

packages/cli-v3/src/entryPoints/managed/heartbeat.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ class RunExecutionSnapshotPoller {
106106

107107
private readonly runFriendlyId: string;
108108
private readonly snapshotFriendlyId: string;
109-
private readonly snapshotPollIntervalSeconds: number;
110109

111110
private readonly handleSnapshotChange: (execution: RunExecutionData) => Promise<void>;
112111

@@ -167,7 +166,7 @@ class RunExecutionSnapshotPoller {
167166

168167
await this.handleSnapshotChange(response.data.execution);
169168
},
170-
intervalMs: this.snapshotPollIntervalSeconds * 1000,
169+
intervalMs: opts.snapshotPollIntervalSeconds * 1000,
171170
leadingEdge: false,
172171
onError: async (error) => {
173172
this.logger.sendDebugLog({
@@ -179,6 +178,10 @@ class RunExecutionSnapshotPoller {
179178
});
180179
}
181180

181+
resetCurrentInterval() {
182+
this.poller.resetCurrentInterval();
183+
}
184+
182185
updateInterval(intervalMs: number) {
183186
this.poller.updateInterval(intervalMs);
184187
}

0 commit comments

Comments
 (0)