mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
v0.3.24: api block fixes
This commit is contained in:
@@ -171,7 +171,8 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
|
||||
try {
|
||||
data = await (contentType.includes('application/json') ? response.json() : response.text())
|
||||
} catch (error) {
|
||||
data = await response.text()
|
||||
// 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)}`
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -399,8 +399,9 @@ async function handleInternalRequest(
|
||||
|
||||
const response = await fetch(fullUrl, requestOptions)
|
||||
|
||||
// Clone the response for error checking while preserving original for transformResponse
|
||||
// Clone the response immediately before any body consumption
|
||||
const responseForErrorCheck = response.clone()
|
||||
const responseForTransform = response.clone()
|
||||
|
||||
// Parse response data for error checking
|
||||
let responseData
|
||||
@@ -468,7 +469,7 @@ async function handleInternalRequest(
|
||||
// Success case: use transformResponse if available
|
||||
if (tool.transformResponse) {
|
||||
try {
|
||||
const data = await tool.transformResponse(response, params)
|
||||
const data = await tool.transformResponse(responseForTransform, params)
|
||||
return data
|
||||
} catch (transformError) {
|
||||
logger.error(`[${requestId}] Transform response error for ${toolId}:`, {
|
||||
|
||||
Reference in New Issue
Block a user