diff --git a/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts b/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts index 68507b9d..15cb7428 100644 --- a/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts +++ b/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts @@ -529,11 +529,33 @@ export async function getPipelineRenderingEngine( method: 'GET', headers: { authorization: getAuthorizationHeader() + }, + next: { + revalidate: 0 } } ); + if (response.ok) { - return await response.json(); + try { + return await response.json(); + } catch (error) { + console.error('Failed to parse successful JSON response:', error); + throw new Error('Parsing error in successful response.'); + } + } + + const contentType = response.headers.get('content-type'); + const responseText = await response.text(); + + if (contentType && contentType.includes('application/json')) { + try { + throw JSON.parse(responseText); + } catch (error) { + console.error('Failed to parse JSON error response:', error); + throw new Error(`Failed to parse JSON error response: ${responseText}`); + } + } else { + throw new Error(`Unexpected non-JSON response: ${responseText}`); } - throw await response.json(); } diff --git a/src/api/manager/workflow.ts b/src/api/manager/workflow.ts index 6520377b..a9d7ca26 100644 --- a/src/api/manager/workflow.ts +++ b/src/api/manager/workflow.ts @@ -378,10 +378,12 @@ export async function stopProduction( } for (const source of production.sources) { - for (const stream_uuid of source.stream_uuids || []) { - await deleteStreamByUuid(stream_uuid).catch((error) => { - Log().error('Failed to delete stream! \nError: ', error); - }); + if (source.type === 'ingest_source') { + for (const stream_uuid of source.stream_uuids || []) { + await deleteStreamByUuid(stream_uuid).catch((error) => { + Log().error('Failed to delete stream! \nError: ', error); + }); + } } } @@ -441,7 +443,7 @@ export async function stopProduction( value: { step: 'remove_pipeline_streams', success: false, - message: 'Unexpected error occured' + message: `Error occurred when removing streams from pipeline: ${e}` } }; } else { @@ -464,7 +466,7 @@ export async function stopProduction( value: { step: 'remove_pipeline_multiviews', success: false, - message: 'Unexpected error occured' + message: `Error occurred when removing multiviews from pipeline: ${e}` } }; } else { @@ -638,7 +640,7 @@ export async function startProduction( return { ok: false, value: [{ step: 'streams', success: false }], - error: 'Could not setup streams: Unexpected error occured' + error: `Could not setup streams: Unexpected error occured: ${e}` }; } return {