Is your Container responding to requests for any hostname / interface / path (even if a 404)?
Is your Container responding to requests for any hostname / interface / path (even if a 404)?
"[HTTP Client] Making POST request to http://localhost:3000/api/write", I get the following error message:dcb4030e8dbbd797c6f34192fba09c75e77c42d32244b52680d3431302e0a7eewriteFile causes the container to lose connectivity, and then it kinda 'hangs'.a03e7cbd-ed24-485c-92c4-eeb9bac1ae5dwriteFile API?writeFile. Interestingly I get this on execute:"Failed to create session" once deployed.
max_instances of 10 and rollout steps of 20, 100 then we can't progress past 20% (aka 2 instances) until those 2 instances have stopped & we've brought them back up with the new settings.sleepAfter kinda has a web server focus where once you respond, sleepAfter starts and then we'll send a SIGTERM to your Container.onActivityExpired lifecycle hook in the Containers class where you can do your own logic to decide if sleepAfter should start counting downonActivityExpired is basically your way to intercept the sleepAfter invocation for nowimport { Container, getContainer } from "@cloudflare/containers";
export class dummy extends Container {
constructor(state, env) {
super(state, env);
// Set envVars in constructor
this.envVars = {
NAME: env.name,
};
}
sleepAfter = "30m";
async onStart() {
console.log("Container started");
}
enableInternet = true;
onStop() {
console.log("Container shut down");
}
onError(error) {
console.log("Error:", error);
}
}
export default {
async fetch(request, env, ctx) {
// Trigger Durable Object
console.log("Manual trigger → starting container");
const container = getContainer(env.DUMMY);
await container.start({
startOptions: {
envVars: {
// You can pass dynamic values here
MANUAL_TRIGGERED_AT: new Date().toISOString(),
},
},
});
return new Response("Container manually triggered and executed", {
status: 200,
});
},
async scheduled(controller, env, ctx) {
console.log("Cron triggered");
const container = getContainer(env.DUMMY);
await container.start({
startOptions: {
envVars: {
CRON_TRIGGERED_AT: new Date().toISOString(),
},
},
});
},
};/**
* Manages isolated sessions for command execution.
* Each session maintains its own state (pwd, env vars, processes).
*/
export class SessionManager {
private sessions = new Map<string, Session>();
async createSession(options: SessionOptions): Promise<Session> {
// Validate cwd if provided - must be absolute path
if (options.cwd) {
if (!options.cwd.startsWith('/')) {
throw new Error(`cwd must be an absolute path starting with '/', got: ${options.cwd}`);
}
}
// Return existing session if it already exists
const existing = this.sessions.get(options.id);
if (existing) {
console.log(`[SessionManager] Returning existing session '${options.id}'`);
return existing;
}
// Create new session only if it doesn't exist
const session = new Session(options);
await session.initialize();
this.sessions.set(options.id, session);
console.log(`[SessionManager] Created new session '${options.id}'`);
return session;
}