()
| 44 | useEffect(() => { |
| 45 | if (!chatId) return; |
| 46 | |
| 47 | // eslint-disable-next-line prefer-const |
| 48 | let pollingInterval: NodeJS.Timeout; |
| 49 | let attemptCount = 0; |
| 50 | const MAX_ATTEMPTS = 60; // About 2 minutes of polling |
| 51 | |
| 52 | const checkProjectStatus = async () => { |
| 53 | attemptCount++; |
| 54 | |
| 55 | try { |
| 56 | await getChatDetails({ |
| 57 | variables: { chatId }, |
| 58 | }); |
| 59 | } catch (err) { |
| 60 | logger.error('Error polling for project:', err); |
| 61 | } |
| 62 | |
| 63 | // Stop polling if project is ready or max attempts reached |
| 64 | if (isReady || attemptCount >= MAX_ATTEMPTS) { |
| 65 | clearInterval(pollingInterval); |
| 66 | |
| 67 | if (attemptCount >= MAX_ATTEMPTS && !isReady) { |
| 68 | setError( |
| 69 | 'Project creation is taking longer than expected. Please check back later.' |
| 70 | ); |
no outgoing calls
no test coverage detected