mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
This reverts commit 8016af60f4.
This commit is contained in:
committed by
GitHub
parent
8016af60f4
commit
8aa0ed19f1
@@ -171,8 +171,7 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
|
||||
try {
|
||||
data = await (contentType.includes('application/json') ? response.json() : response.text())
|
||||
} catch (error) {
|
||||
// If response body reading fails, we can't retry reading - just use error message
|
||||
data = `Failed to parse response: ${error instanceof Error ? error.message : String(error)}`
|
||||
data = await response.text()
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -399,9 +399,8 @@ async function handleInternalRequest(
|
||||
|
||||
const response = await fetch(fullUrl, requestOptions)
|
||||
|
||||
// Clone the response immediately before any body consumption
|
||||
// Clone the response for error checking while preserving original for transformResponse
|
||||
const responseForErrorCheck = response.clone()
|
||||
const responseForTransform = response.clone()
|
||||
|
||||
// Parse response data for error checking
|
||||
let responseData
|
||||
@@ -469,7 +468,7 @@ async function handleInternalRequest(
|
||||
// Success case: use transformResponse if available
|
||||
if (tool.transformResponse) {
|
||||
try {
|
||||
const data = await tool.transformResponse(responseForTransform, params)
|
||||
const data = await tool.transformResponse(response, params)
|
||||
return data
|
||||
} catch (transformError) {
|
||||
logger.error(`[${requestId}] Transform response error for ${toolId}:`, {
|
||||
|
||||
Reference in New Issue
Block a user