@@ -107,11 +107,6 @@ export class Container<Env = unknown> extends DurableObject<Env> {
107107 } ) ;
108108
109109 this . container = ctx . container ;
110-
111- // we are not setting up a global monitor because we cannot guarantee the DO will be alive when the container stops
112- // if (this.container.running) {
113- // this.monitor ??= this.setupMonitorCallbacks();
114- // }
115110 }
116111 /**
117112 * Gets the current state of the container
@@ -273,7 +268,8 @@ export class Container<Env = unknown> extends DurableObject<Env> {
273268 } ) ;
274269 }
275270
276- // we are not setting up a global monitor because we cannot guarantee the DO will be alive when the container stops
271+ // we are not setting up a monitor because we cannot guarantee the DO will be alive when the container stops
272+ // but we will want to in the future
277273 // this.monitor ??= this.setupMonitorCallbacks();
278274 }
279275
@@ -302,30 +298,7 @@ export class Container<Env = unknown> extends DurableObject<Env> {
302298 public onStart ( ) : void | Promise < void > {
303299 // Default implementation does nothing
304300 }
305-
306- // We are not implementing onStop for now because there is no guarantee the DO will be alive when the container stops
307- // and we don't have a way for cloudchamberd to wake up the DO
308- // /**
309- // * Lifecycle method called when container shuts down
310- // * Override this method in subclasses to handle Container stopped events
311- // * @param params - Object containing exitCode and reason for the stop
312- // */
313- // public onStop(_: StopParams): void | Promise<void> {
314- // // Default implementation does nothing
315- // }
316-
317- // We are not implementing onStop for now because there is no guarantee the DO will be alive when the container stops
318- // and we don't have a way for cloudchamberd to wake up the DO
319- /**
320- * Error handler for container errors
321- * Override this method in subclasses to handle container errors
322- * @param error - The error that occurred
323- * @returns Can return any value or throw the error
324- */
325- // public onError(error: unknown): any {
326- // console.error('Container error:', error);
327- // throw error;
328- // }
301+ // We will implement onStop and onError when cloudchamberd can reach out to the DO
329302
330303 // this should not be overridden by the user
331304 override async fetch ( request : Request ) : Promise < Response > {
@@ -343,33 +316,4 @@ export class Container<Env = unknown> extends DurableObject<Env> {
343316
344317 return await tcpPort . fetch ( request . url . replace ( 'https:' , 'http:' ) , request ) ;
345318 }
346-
347- // we are not setting up a global monitor because we cannot guarantee the DO will be alive when the container stops
348- // private monitor: Promise<unknown> | undefined;
349-
350- // we are not setting up a global monitor because we cannot guarantee the DO will be alive when the container stops
351- // private async setupMonitorCallbacks() {
352- // return (
353- // this.container
354- // .monitor()
355- // .then(async () => {
356- // await this.ctx.blockConcurrencyWhile(async () => {
357- // await this.onStop({ exitCode: 0, reason: 'exit' });
358- // });
359- // })
360- // .catch(async (error: unknown) => {
361- // await this.ctx.blockConcurrencyWhile(async () => {
362- // await this.onError(error);
363- // });
364- // if (isNoInstanceError(error)) {
365- // // we will inform later (TODO: why?? when??)
366- // return;
367- // }
368- // })
369- // //
370- // .finally(() => {
371- // this.monitor = undefined;
372- // })
373- // );
374- // }
375319}
0 commit comments