chore(frontend): Max retries toevoegen
Frontend unittesten hoogstens 60 retries van 1 seconde
This commit is contained in:
		
							parent
							
								
									8c338d8d56
								
							
						
					
					
						commit
						93624cdc6a
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -3,14 +3,14 @@ import { ChildProcess } from "node:child_process"; | |||
| 
 | ||||
| let backendProcess: ChildProcess; | ||||
| 
 | ||||
| async function waitForEndpoint(url: string, delay = 1000): Promise<void> { | ||||
| async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise<void> { | ||||
|     try { | ||||
|         await fetch(url); | ||||
|     } catch { | ||||
|         // Endpoint is not ready yet
 | ||||
|         await new Promise((resolve) => setTimeout(resolve, delay)); | ||||
|         // Retry
 | ||||
|         await waitForEndpoint(url, delay); | ||||
|         await waitForEndpoint(url, delay, retries - 1); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue