dengliming opened a new issue, #602:
URL: https://github.com/apache/shenyu-dashboard/issues/602
## Description
`request()` in `src/utils/request.js` ends with a `.catch` that handles the
401 case and then returns nothing. Every other failure (non-2xx HTTP status,
network error, `response.json()` parse error, and even the 401 case itself)
resolves the promise to `undefined` instead of rejecting. Every dva effect then
does `json.code === 200` / `response.data` on `undefined` and throws a
`TypeError` inside the saga. Because `dva-loading` dispatches SHOW before the
effect and HIDE only after it returns normally, the throw leaves
`loading.effects[...]` at `true` forever.
`response.json()` is also called for `204 No Content` responses (lines
120-123), which rejects on the empty body and goes down the same path.
## Location
(Lines refer to `master @ 83969a5`.)
- `src/utils/request.js:113-141`
- Consumers that will throw on `undefined`: `src/models/login.js:31-34`
(`response.data`), `src/models/global.js` fetchPermission (rendered as an
endless `<Spin>` by `src/utils/AuthRoute.js:299`), `src/models/alert.js:32-37`
(`payload.page.totalCount`), `src/models/scale.js` fetchPolicy
(`response.data.sort`), and practically every other `*fetch` effect.
## Impact
- A 500 from `/platform/login` throws inside `login/login`; the login page
shows nothing and the submit button stays in loading state.
- A failing `/permission/getUserPermissionByNamespace` makes `AuthRoute`
spin forever with no error message.
- Any list page whose backend call fails is stuck in loading and the user
has no feedback beyond the generic notification.
## Suggested fix
Either re-throw from the `catch` after handling 401 (so callers can
`try/catch` in their effects) or resolve to a normalized error object such as
`{ code: status, message }` and make callers use `json?.code`. Also skip
`response.json()` for 204 responses. Consider wrapping effects in `try/finally`
so dva-loading always hides.
## Related existing
None
--
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]