Closed aymericdelab closed 1 month ago
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
eternum | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Jun 14, 2024 10:24am |
โฑ๏ธ Estimated effort to review [1-5] | 3 |
๐งช Relevant tests | No |
๐ Security concerns | No |
โก Key issues to review |
Error Handling: The removal of the `finally` block in `useExplore.tsx` might lead to scenarios where overrides are not removed if an exception occurs before the catch block. Consider adding finally to ensure cleanup. |
Logging: Direct use of `console.log` for error logging in `useExplore.tsx` is found. It's better to use a more robust logging approach or error handling strategy. | |
Commented Code: There are `todo` comments related to stamina in both `useExplore.tsx` and `useTravel.tsx`. Ensure that these todos are addressed or tracked in your project management tool. |
Category | Suggestion | Score |
Error handling |
Add error handling in the
___
**The | 9 |
Improve error handling in the explore function to include retries or user feedback___ **Consider handling the promise rejection fromexplore function more robustly. Currently, the catch block only logs the error and updates the UI, but it might be beneficial to also retry the operation or provide a user feedback mechanism.** [client/src/hooks/helpers/useExplore.tsx [145-154]](https://github.com/BibliothecaDAO/eternum/pull/931/files#diff-45821874b656c15cf5d9d6a603afd6d4858df5008f6353317b5a2d75482aa9a9R145-R154) ```diff explore({ unit_id: explorerId, direction, signer: account, }).catch((e) => { - removeHex(path[1].x - FELT_CENTER, path[1].y - FELT_CENTER); - Position.removeOverride(overrideId); - setAnimationPaths([...prevPaths, { id: explorerId, path: [path[path.length - 1]], enemy: false }]); - console.log("error exploring", e); + handleExploreError(e, explorerId, path, overrideId); }); ``` Suggestion importance[1-10]: 7Why: Enhancing error handling to include retries or user feedback can improve the user experience and make the application more resilient to transient errors. However, the suggestion is somewhat general and lacks specific implementation details. | 7 | |
Best practice |
Replace console logging with a robust error handling mechanism___ **Replace theconsole.log with a more robust error handling mechanism. Using console.log for error reporting in production code is not recommended as it does not provide a way to centrally manage or track errors. Consider using a logging library that supports error level logging and possibly remote error reporting.** [client/src/hooks/helpers/useExplore.tsx [153]](https://github.com/BibliothecaDAO/eternum/pull/931/files#diff-45821874b656c15cf5d9d6a603afd6d4858df5008f6353317b5a2d75482aa9a9R153-R153) ```diff -console.log("error exploring", e); +logError("error exploring", e); ``` Suggestion importance[1-10]: 8Why: Replacing `console.log` with a more robust error handling mechanism is a best practice for production code. It improves error tracking and management, which is crucial for maintaining the application. | 8 |
Possible issue |
Ensure proper initialization of the
___
**Ensure that the | 6 |
PR Type
Bug fix, Enhancement
Description
Stamina
component to the list of overridable components.explore
function by removing thefinally
block and adjusted error handling.optimisticTravelHex
for handling optimistic updates in travel and integrated it intotravelToHex
.travelToHex
to revert position overrides and update animation paths correctly.Changes walkthrough ๐
createClientComponents.ts
Add Stamina component to client components
client/src/dojo/createClientComponents.ts - Added `Stamina` component to the list of overridable components.
useTravel.tsx
Add optimistic travel and improve error handling
client/src/hooks/helpers/useTravel.tsx
optimisticTravelHex
for handling optimisticupdates.
optimisticTravelHex
into thetravelToHex
function.travelToHex
to revert position overrides.useExplore.tsx
Simplify explore function and improve error handling
client/src/hooks/helpers/useExplore.tsx
explore
function by removing thefinally
block.correctly.