3434 print_error ,
3535 print_info ,
3636 print_success ,
37- print_warning ,
3837)
3938
4039from .wrangler_wrapper import wrangler_deploy
@@ -291,31 +290,30 @@ async def _deploy_with_retry(
291290 api_key: API key for authentication
292291 project_dir: Directory containing the project files
293292 mcp_app_client: MCP App client for API calls
294- retry_count: Number of retry attempts
293+ retry_count: Number of retry attempts for deployment
295294
296295 Returns:
297296 Deployed app information
298297 """
298+ # Step 1: Bundle once (no retry - if this fails, fail immediately)
299+ try :
300+ wrangler_deploy (
301+ app_id = app_id ,
302+ api_key = api_key ,
303+ project_dir = project_dir ,
304+ )
305+ except Exception as e :
306+ raise CLIError (f"Bundling failed: { str (e )} " ) from e
307+
308+ # Step 2: Deployment API call with retries if needed
299309 attempt = 0
300310
301- async def _perform_deployment ():
311+ async def _perform_api_deployment ():
302312 nonlocal attempt
303313 attempt += 1
304314
305315 attempt_suffix = f" (attempt { attempt } /{ retry_count } )" if attempt > 1 else ""
306316
307- try :
308- wrangler_deploy (
309- app_id = app_id ,
310- api_key = api_key ,
311- project_dir = project_dir ,
312- )
313- except Exception as e :
314- if attempt < retry_count :
315- print_warning (f"Bundling failed on attempt { attempt } /{ retry_count } : { str (e )} " )
316- raise
317-
318- # Deploy app
319317 with Progress (
320318 SpinnerColumn (spinner_name = "arrow3" ),
321319 TextColumn ("[progress.description]{task.description}" ),
@@ -325,18 +323,16 @@ async def _perform_deployment():
325323 app = await mcp_app_client .deploy_app (app_id = app_id )
326324 progress .update (deploy_task , description = f"✅ MCP App deployed successfully{ attempt_suffix } !" )
327325 return app
328- except Exception as e :
326+ except Exception :
329327 progress .update (deploy_task , description = f"❌ Deployment failed{ attempt_suffix } " )
330- if attempt < retry_count :
331- print_warning (f"Deployment failed on attempt { attempt } /{ retry_count } : { str (e )} " )
332328 raise
333329
334330 if retry_count > 1 :
335- print_info (f"Deployment configured with up to { retry_count } attempts" )
331+ print_info (f"Deployment API configured with up to { retry_count } attempts" )
336332
337333 try :
338334 return await retry_async_with_exponential_backoff (
339- _perform_deployment ,
335+ _perform_api_deployment ,
340336 max_attempts = retry_count ,
341337 initial_delay = 1.0 ,
342338 backoff_multiplier = 2.0 ,
0 commit comments