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; | let backendProcess: ChildProcess; | ||||||
| 
 | 
 | ||||||
| async function waitForEndpoint(url: string, delay = 1000): Promise<void> { | async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise<void> { | ||||||
|     try { |     try { | ||||||
|         await fetch(url); |         await fetch(url); | ||||||
|     } catch { |     } catch { | ||||||
|         // Endpoint is not ready yet
 |         // Endpoint is not ready yet
 | ||||||
|         await new Promise((resolve) => setTimeout(resolve, delay)); |         await new Promise((resolve) => setTimeout(resolve, delay)); | ||||||
|         // Retry
 |         // Retry
 | ||||||
|         await waitForEndpoint(url, delay); |         await waitForEndpoint(url, delay, retries - 1); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue