(userId: string)
| 112 | * @category BrowserManagement-Controller |
| 113 | */ |
| 114 | export const createRemoteBrowserForRun = (userId: string): string => { |
| 115 | if (!userId) { |
| 116 | logger.log('error', 'createRemoteBrowserForRun: Missing required parameter userId'); |
| 117 | throw new Error('userId is required'); |
| 118 | } |
| 119 | |
| 120 | const id = uuid(); |
| 121 | |
| 122 | const slotReserved = browserPool.reserveBrowserSlotAtomic(id, userId, "run"); |
| 123 | if (!slotReserved) { |
| 124 | logger.log('warn', `Cannot create browser for user ${userId}: no available slots`); |
| 125 | throw new Error('User has reached maximum browser limit'); |
| 126 | } |
| 127 | |
| 128 | logger.log('info', `createRemoteBrowserForRun: Reserved slot ${id} for user ${userId}`); |
| 129 | |
| 130 | initializeBrowserAsync(id, userId) |
| 131 | .catch((error: any) => { |
| 132 | logger.log('error', `Unhandled error in initializeBrowserAsync for browser ${id}: ${error.message}`); |
| 133 | browserPool.failBrowserSlot(id); |
| 134 | }); |
| 135 | |
| 136 | return id; |
| 137 | }; |
| 138 | |
| 139 | /** |
| 140 | * Terminates a remote browser recording session |
no test coverage detected