You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Gotenberg API fails, it provides valuable error details in the response body that explain the failure reason. Currently, in https://github.com/cherfia/chromiumly/blob/main/src/common/gotenberg.utils.ts, the fetch method discards these details and only throws the HTTP status code and status text, making production debugging difficult. For example, the current error output is limited to:
400 Bad Request
or
503 Service Unavailable
However, Gotenberg includes specific error details in the response body. By modifying the fetch method to capture and include these details, we can better understand why requests fail. Below is the improved implementation (for our use case).
Our patch version for reference
import{GotenbergError}from'#/exceptions/error';import{GotenbergUtils}from'chromiumly/dist/common';GotenbergUtils.fetch=asyncfunction(endpoint: string,data: FormData,username?: string,password?: string,customHttpHeaders?: Record<string,string>): Promise<Buffer>{console.log('fetch',endpoint,data,username,password,customHttpHeaders);constheaders: Record<string,string>={ ...customHttpHeaders};if(username&&password){constauthHeader='Basic '+Buffer.from(username+':'+password).toString('base64');headers.Authorization=authHeader;}constresponse=awaitfetch(endpoint,{method: 'POST',body: data,
headers
});if(!response.ok){letmessage=awaitresponse.text().catch(()=>response.statusText);if(response.status===503){message='Your request is taking longer than expected or the generated file is too large.';}thrownewGotenbergError(message,response.status);}constarrayBuffer=awaitresponse.arrayBuffer();returnBuffer.from(arrayBuffer);};
Problem Description
When the Gotenberg API fails, it provides valuable error details in the response body that explain the failure reason. Currently, in https://github.com/cherfia/chromiumly/blob/main/src/common/gotenberg.utils.ts, the fetch method discards these details and only throws the HTTP status code and status text, making production debugging difficult. For example, the current error output is limited to:
or
However, Gotenberg includes specific error details in the response body. By modifying the fetch method to capture and include these details, we can better understand why requests fail. Below is the improved implementation (for our use case).
Our patch version for reference
The text was updated successfully, but these errors were encountered: