Skip to content

fix: handle coingecko 404 responses gracefully#3914

Open
kev1n-peters wants to merge 1 commit into
developmentfrom
coingecko-not-found-fix
Open

fix: handle coingecko 404 responses gracefully#3914
kev1n-peters wants to merge 1 commit into
developmentfrom
coingecko-not-found-fix

Conversation

@kev1n-peters

Copy link
Copy Markdown
Contributor

fixes seeing errors in the console related to coins not being found on coingecko, e.g.:

hook.js:608 Coingecko error Error: string message has invalid length for format hex
    at 6900-4003b15ccf3279d5.js:7:431211
    at h.stringToUint8Array (6900-4003b15ccf3279d5.js:7:431502)
    at new h (6900-4003b15ccf3279d5.js:7:430597)
    at c (6900-4003b15ccf3279d5.js:467:47180)
    at b.parseAddress (6900-4003b15ccf3279d5.js:1479:25102)
    at b.chainAddress (6900-4003b15ccf3279d5.js:1479:25203)
    at b.tokenId (6900-4003b15ccf3279d5.js:1479:25277)
    at 6900-4003b15ccf3279d5.js:483:442697
    at Array.map (<anonymous>)
    at 6900-4003b15ccf3279d5.js:483:442675
    ```

@netlify

netlify Bot commented Nov 10, 2025

Copy link
Copy Markdown

Deploy Preview for wormhole-connect-mainnet ready!

Name Link
🔨 Latest commit cf818f2
🔍 Latest deploy log https://app.netlify.com/projects/wormhole-connect-mainnet/deploys/6912693da3acaa0008aba9f2
😎 Deploy Preview https://deploy-preview-3914--wormhole-connect-mainnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Nov 10, 2025

Copy link
Copy Markdown

Deploy Preview for wormhole-connect ready!

Name Link
🔨 Latest commit cf818f2
🔍 Latest deploy log https://app.netlify.com/projects/wormhole-connect/deploys/6912693d8cbbcf000761c3b6
😎 Deploy Preview https://deploy-preview-3914--wormhole-connect.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/utils/coingecko.ts
headers,
})
.then((resp) => resp.json())
.then((resp) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is quite nested and is hard to read, but has a deterministic output. I think it would greatly benefit from claude auto-refactoring. Before refactoring we can get claude to write a whole bunch of tests, then get claude to refactor and tests should still work. Obvious fixes can be switching to async/await, moving coingecko call out for fetching native vs non native tokens, moving request building and response parsing/mapping out as functions, reduce loops after loops (for eg last few lines maps, filters, flats and still loops), etc.

Comment thread src/utils/coingecko.ts
console.error(
`Coingecko request failed with status ${resp.status}: ${path}`,
);
return null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not throw since we are already logging below and returning null

Comment thread src/utils/coingecko.ts
if (data['error'] !== undefined || data['error_code'] !== undefined) {
if (data === null) {
// Request failed (e.g., 404, network error)
resolve([]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why resolve and not reject like other errors below? Or inversely, why reject below and not return []. In the end all its checking if its fullfilled or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants