(
queue: SqsWorkerMode,
compilationEnvironment: CompilationEnvironment,
persistentSender: PersistentEventsSender,
)
| 145 | } |
| 146 | |
| 147 | async function doOneExecution( |
| 148 | queue: SqsWorkerMode, |
| 149 | compilationEnvironment: CompilationEnvironment, |
| 150 | persistentSender: PersistentEventsSender, |
| 151 | ) { |
| 152 | if (!persistentSender.isReadyForNewMessages()) { |
| 153 | logger.debug( |
| 154 | `Skipping execution message pull - WebSocket not ready or has ${persistentSender.getPendingAckCount()} pending acknowledgments`, |
| 155 | ); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | const msg = await queue.pop(); |
| 160 | if (msg?.guid) { |
| 161 | const startTime = Date.now(); |
| 162 | try { |
| 163 | const executor = new LocalExecutionEnvironment(compilationEnvironment); |
| 164 | await executor.downloadExecutablePackage(msg.hash); |
| 165 | const result = await executor.execute(msg.params); |
| 166 | |
| 167 | const endTime = Date.now(); |
| 168 | const duration = endTime - startTime; |
| 169 | |
| 170 | await sendResultViaWebsocket(persistentSender, msg.guid, result, duration); |
| 171 | } catch (e) { |
| 172 | // todo: e is undefined somehow? |
| 173 | logger.error(e); |
| 174 | |
| 175 | const endTime = Date.now(); |
| 176 | const duration = endTime - startTime; |
| 177 | |
| 178 | await sendResultViaWebsocket( |
| 179 | persistentSender, |
| 180 | msg.guid, |
| 181 | { |
| 182 | code: -1, |
| 183 | stderr: [{text: 'Internal error when remotely executing'}], |
| 184 | stdout: [], |
| 185 | okToCache: false, |
| 186 | timedOut: false, |
| 187 | filenameTransform: f => f, |
| 188 | execTime: 0, |
| 189 | }, |
| 190 | duration, |
| 191 | ); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | export function startExecutionWorkerThread( |
| 197 | ceProps: PropertyGetter, |
no test coverage detected