feat(api): implement logging for canceled API requests to improve error handling and debugging
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m7s

This commit is contained in:
2026-02-24 12:41:44 +07:00
parent 4370e13524
commit 69e360b940
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
{\
{"sessionId":"378b5f","runId":"baseline","hypothesisId":"H1_H2","location":"frontend/src/lib/api.js:request","message":"API request started","data":{"method":"GET","url":"/alerts"},"timestamp":1771911695277}
+16
View File
@@ -64,6 +64,14 @@ api.interceptors.response.use(
return response;
},
async (error) => {
const isCanceled = error?.code === 'ERR_CANCELED' || error?.name === 'CanceledError' || error?.name === 'AbortError';
if (isCanceled) {
// #region agent log
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:retry-skip-canceled',message:'Skip retry for canceled request',data:{method:String(error?.config?.method||'get').toUpperCase(),url:String(error?.config?.url||''),code:String(error?.code||'')},timestamp:Date.now()})}).catch(()=>{});
// #endregion
return Promise.reject(error);
}
const config = error?.config || {};
const method = String(config.method || 'get').toUpperCase();
@@ -107,6 +115,14 @@ api.interceptors.response.use(
api.interceptors.response.use(
(res) => res,
(err) => {
const isCanceled = err?.code === 'ERR_CANCELED' || err?.name === 'CanceledError' || err?.name === 'AbortError';
if (isCanceled) {
// #region agent log
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:global-skip-canceled',message:'Skip global error handling for canceled request',data:{method:String(err?.config?.method||'get').toUpperCase(),url:String(err?.config?.url||''),code:String(err?.code||'')},timestamp:Date.now()})}).catch(()=>{});
// #endregion
return Promise.reject(err);
}
// #region agent log
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:error',message:'API response error',data:{method:String(err?.config?.method||'get').toUpperCase(),url:String(err?.config?.url||''),status:Number(err?.response?.status||0),code:String(err?.response?.data?.code||err?.code||'')},timestamp:Date.now()})}).catch(()=>{});
// #endregion