majin1102 commented on code in PR #4075:
URL: https://github.com/apache/amoro/pull/4075#discussion_r2777521719
##########
amoro-web/src/views/tables/components/Details.vue:
##########
@@ -124,6 +128,22 @@ async function getTableDetails() {
setBaseDetailInfo()
}
catch (error) {
+ const errorMessage = (error as Error)?.message || ''
+ const isNotFoundError = /not exist|not found/i.test(errorMessage)
Review Comment:
Suggestions from AI:
There is a potential race condition in getTableDetails when the route
changes while a previous request is still in flight. params is a computed value
based on route.query, so during the await getTableDetail(...) call the user can
switch from table A to table B, causing params.value to point to table B.
When the slow request for table A finally fails with "Table does not exist"
/ "table not found", the catch block reads catalogName, dbName, and tableName
again from params.value. At that time params.value may already refer to table
B, so we will:
- remove the cached table key from localStorage,
- emit tableNotFound for table B, and
- redirect the user back to /tables.
- This means a valid table B can be mistakenly treated as non-existent if a
previous request for table A fails later, which is confusing for users.
Suggestion: take a snapshot of the parameters at the beginning of
getTableDetails and use that snapshot consistently in both the request and the
error handling, for example:
```
const getTableDetails = async () => {
isLoading.value = true;
const requestParams = { ...params.value };
const { catalogName, dbName, tableName } = requestParams;
try {
const res = await getTableDetail({
type: requestParams.tableType,
name: tableName,
database: dbName,
catalog: catalogName,
});
tableDetails.value = res?.data?.details;
getTableOptimizeInfo();
} catch (error: any) {
const e = error as AxiosError<any> & { data: { message?: string } };
const message = e?.data?.message;
if (message && (message.includes("Table does not exist") ||
message.includes("table not found"))) {
localStorage.removeItem(STORAGE_TABLE_KEY);
emit("tableNotFound", `${catalogName}/${dbName}/${tableName}`);
router.replace({ path: "/tables", query: {} });
return;
}
} finally {
isLoading.value = false;
}
};
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]