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

Function createReadyFetchProxyProc

apps/sim/lib/execution/isolated-vm.test.ts:133–171  ·  view source on GitHub ↗
(fetchMessage: { url: string; optionsJson?: string })

Source from the content-addressed store, hash-verified

131}
132
133function createReadyFetchProxyProc(fetchMessage: { url: string; optionsJson?: string }): MockProc {
134 const proc = createBaseProc()
135 let currentExecutionId = 0
136
137 proc.send = (message: unknown) => {
138 const msg = message as { type?: string; executionId?: number; request?: { requestId?: string } }
139
140 if (msg.type === 'execute') {
141 currentExecutionId = msg.executionId ?? 0
142 setImmediate(() => {
143 proc.emit('message', {
144 type: 'fetch',
145 fetchId: 1,
146 requestId: msg.request?.requestId ?? 'fetch-test',
147 url: fetchMessage.url,
148 optionsJson: fetchMessage.optionsJson,
149 })
150 })
151 return true
152 }
153
154 if (msg.type === 'fetchResponse') {
155 const fetchResponse = message as { response?: string }
156 setImmediate(() => {
157 proc.emit('message', {
158 type: 'result',
159 executionId: currentExecutionId,
160 result: { result: fetchResponse.response ?? '', stdout: '' },
161 })
162 })
163 return true
164 }
165
166 return true
167 }
168
169 setImmediate(() => proc.emit('message', { type: 'ready' }))
170 return proc
171}
172
173const { mockSpawn, mockExecSync, mockSanitizeUrl, mockEnv } = vi.hoisted(() => ({
174 mockSpawn: vi.fn(),

Callers 1

Calls 1

createBaseProcFunction · 0.85

Tested by

no test coverage detected