MCPcopy Index your code
hub / github.com/simstudioai/sim / cleanupWorker

Function cleanupWorker

apps/sim/lib/execution/isolated-vm.ts:840–872  ·  view source on GitHub ↗
(workerId: number)

Source from the content-addressed store, hash-verified

838}
839
840function cleanupWorker(workerId: number) {
841 const workerInfo = workers.get(workerId)
842 if (!workerInfo) return
843
844 if (workerInfo.idleTimeout) {
845 clearTimeout(workerInfo.idleTimeout)
846 }
847
848 workerInfo.process.kill()
849
850 for (const [id, pending] of workerInfo.pendingExecutions) {
851 clearTimeout(pending.timeout)
852 totalActiveExecutions--
853 const owner = ownerStates.get(pending.ownerKey)
854 if (owner) {
855 owner.activeExecutions = Math.max(0, owner.activeExecutions - 1)
856 maybeCleanupOwner(owner.ownerKey)
857 }
858 pending.resolve({
859 result: null,
860 stdout: '',
861 error: {
862 message: 'Code execution failed unexpectedly. Please try again.',
863 name: 'Error',
864 isSystemError: true,
865 },
866 })
867 workerInfo.pendingExecutions.delete(id)
868 }
869 workerInfo.activeExecutions = 0
870
871 workers.delete(workerId)
872}
873
874function resetWorkerIdleTimeout(workerId: number) {
875 const workerInfo = workers.get(workerId)

Callers 4

handleWorkerMessageFunction · 0.85
resetWorkerIdleTimeoutFunction · 0.85
spawnWorkerFunction · 0.85
dispatchToWorkerFunction · 0.85

Calls 4

maybeCleanupOwnerFunction · 0.85
getMethod · 0.65
resolveMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected