@@ -36,6 +36,7 @@ export interface Env {
3636 OS_BASE_URL ?: string ;
3737 OS_TRUSTED_ORIGINS ?: string ;
3838 OS_COOKIE_DOMAIN ?: string ;
39+ OS_ROOT_DOMAIN ?: string ;
3940 GOOGLE_CLIENT_ID ?: string ;
4041 GOOGLE_CLIENT_SECRET ?: string ;
4142 GITHUB_CLIENT_ID ?: string ;
@@ -94,7 +95,7 @@ const FORWARDED_ENV_KEYS: readonly (keyof Env)[] = [
9495 // auth
9596 'AUTH_SECRET' , 'OS_AUTH_SECRET' ,
9697 'AUTH_BASE_URL' , 'OS_BASE_URL' ,
97- 'OS_TRUSTED_ORIGINS' , 'OS_COOKIE_DOMAIN' ,
98+ 'OS_TRUSTED_ORIGINS' , 'OS_COOKIE_DOMAIN' , 'OS_ROOT_DOMAIN' ,
9899 'GOOGLE_CLIENT_ID' , 'GOOGLE_CLIENT_SECRET' ,
99100 'GITHUB_CLIENT_ID' , 'GITHUB_CLIENT_SECRET' ,
100101 // cloud client
@@ -132,13 +133,59 @@ export class ObjectOSContainer extends Container<Env> {
132133 enableInternet = true ;
133134 requiredPorts = [ 3000 ] ;
134135
136+ /**
137+ * Cold start budget for the Node app to bind port 3000. The default
138+ * in `@cloudflare/containers` is 20s which is not enough for a fresh
139+ * boot that has to open a remote DB connection + run schema sync for
140+ * every registered `sys_*` object. See apps/cloud/cloudflare/worker.ts
141+ * for the full rationale — this is the same override.
142+ */
143+ private readonly PORT_READY_TIMEOUT_MS = 120_000 ;
144+
145+ override async startAndWaitForPorts (
146+ portsOrArgs ?: any ,
147+ cancellationOptions ?: any ,
148+ startOptions ?: any ,
149+ ) : Promise < void > {
150+ const TIMEOUT = this . PORT_READY_TIMEOUT_MS ;
151+ if (
152+ portsOrArgs !== null &&
153+ typeof portsOrArgs === 'object' &&
154+ ! Array . isArray ( portsOrArgs ) &&
155+ ( 'ports' in portsOrArgs || 'cancellationOptions' in portsOrArgs || 'startOptions' in portsOrArgs )
156+ ) {
157+ const inner = { ...( portsOrArgs . cancellationOptions ?? { } ) } ;
158+ delete inner . abort ;
159+ const merged = {
160+ ...portsOrArgs ,
161+ cancellationOptions : {
162+ portReadyTimeoutMS : TIMEOUT ,
163+ instanceGetTimeoutMS : TIMEOUT ,
164+ ...inner ,
165+ } ,
166+ } ;
167+ return super . startAndWaitForPorts ( merged ) ;
168+ }
169+ const inner = { ...( cancellationOptions ?? { } ) } ;
170+ delete inner . abort ;
171+ const merged = {
172+ portReadyTimeoutMS : TIMEOUT ,
173+ instanceGetTimeoutMS : TIMEOUT ,
174+ ...inner ,
175+ } ;
176+ return super . startAndWaitForPorts ( portsOrArgs , merged , startOptions ) ;
177+ }
178+
135179 envVars : Record < string , string > = {
136180 NODE_ENV : 'production' ,
137181 PORT : '3000' ,
138182 HOST : '0.0.0.0' ,
139183 OS_KERNEL_CACHE_SIZE : '50' ,
140184 OS_KERNEL_TTL_MS : '1800000' ,
141185 OS_ENV_CACHE_TTL_MS : '300000' ,
186+ // Schema sync against a cold remote DB easily exceeds Workers'
187+ // ~30s inbound budget; run migrations out of band before deploy.
188+ OS_SKIP_SCHEMA_SYNC : '1' ,
142189 } ;
143190
144191 constructor ( state : DurableObjectState , env : Env ) {
0 commit comments