From 520174aacdd1a5e95ffb4e559a2987a713d84aed Mon Sep 17 00:00:00 2001 From: Gabi Villalonga Simon Date: Mon, 15 Dec 2025 13:34:04 -0600 Subject: [PATCH] make the ping hostname configurable --- src/lib/container.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/container.ts b/src/lib/container.ts index b94292e..d049dd5 100644 --- a/src/lib/container.ts +++ b/src/lib/container.ts @@ -223,6 +223,14 @@ export class Container extends DurableObject { entrypoint: ContainerStartOptions['entrypoint']; enableInternet: ContainerStartOptions['enableInternet'] = true; + // pingEndpoint is the host and path value that the class will use to send a request to the container and check if the + // instance is ready. + // + // The user does not have to implement this route by any means, + // but it's still useful if you want to control the path that + // the Container class uses to send HTTP requests to. + pingEndpoint: string = 'ping'; + // ========================= // PUBLIC INTERFACE // ========================= @@ -448,7 +456,7 @@ export class Container extends DurableObject { for (let i = 0; i < tries; i++) { try { const combinedSignal = addTimeoutSignal(waitOptions.signal, PING_TIMEOUT_MS); - await tcpPort.fetch('http://ping', { signal: combinedSignal }); + await tcpPort.fetch(`http://${this.pingEndpoint}`, { signal: combinedSignal }); // Successfully connected to this port console.log(`Port ${port} is ready`);