File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,16 @@ async def should_terminate():
437437 SandboxState .BUILD_FAILED ,
438438 ]
439439
440+ pending_build_start = time .time ()
441+
440442 while response_ref ["response" ].state == SandboxState .PENDING_BUILD :
443+ if timeout :
444+ elapsed = time .time () - pending_build_start
445+ if elapsed > timeout :
446+ raise DaytonaError (
447+ f"Sandbox build has been pending for more than { timeout } seconds."
448+ f"Please check the sandbox state again later."
449+ )
441450 await asyncio .sleep (1 )
442451 response_ref ["response" ] = await self ._sandbox_api .get_sandbox (response_ref ["response" ].id )
443452
Original file line number Diff line number Diff line change @@ -398,7 +398,16 @@ def should_terminate():
398398 SandboxState .BUILD_FAILED ,
399399 ]
400400
401+ pending_build_start = time .time ()
402+
401403 while response_ref ["response" ].state == SandboxState .PENDING_BUILD :
404+ if timeout :
405+ elapsed = time .time () - pending_build_start
406+ if elapsed > timeout :
407+ raise DaytonaError (
408+ f"Sandbox build has been pending for more than { timeout } seconds."
409+ f"Please check the sandbox state again later."
410+ )
402411 time .sleep (1 )
403412 response_ref ["response" ] = self ._sandbox_api .get_sandbox (response_ref ["response" ].id )
404413
Original file line number Diff line number Diff line change @@ -505,7 +505,17 @@ export class Daytona {
505505 SandboxState . BUILD_FAILED ,
506506 ]
507507
508+ const pendingBuildStart = Date . now ( )
509+
508510 while ( sandboxInstance . state === SandboxState . PENDING_BUILD ) {
511+ if ( options . timeout ) {
512+ const elapsed = ( Date . now ( ) - pendingBuildStart ) / 1000
513+ if ( elapsed > options . timeout ) {
514+ throw new DaytonaError (
515+ `Sandbox build has been pending for more than ${ options . timeout } seconds. Please check the sandbox state again later.` ,
516+ )
517+ }
518+ }
509519 await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
510520 sandboxInstance = ( await this . sandboxApi . getSandbox ( sandboxInstance . id ) ) . data
511521 }
You can’t perform that action at this time.
0 commit comments