3box-js icon indicating copy to clipboard operation
3box-js copied to clipboard

404 Errors reported from 3Box JS library even when wrapped in try/catch

Open andygray opened this issue 6 years ago • 3 comments

Describe the bug

We are pulling back public display names from our space - some addresses do not have names. We see lots of 404 errors in the console although we believe this is a valid use-case (and we like a nice error free console generally).


        // Try open space
        const niftySpace = await this._getSpaceSafe(account);
        if (niftySpace && niftySpace[SQUAD_NAME]) {
            return niftySpace[SQUAD_NAME];
        }

        // Try get public name
        const profile = await this._getProfileSafe(account);
        if (profile && profile.name) {
            return profile.name;
        }

        // Fallback to eth account
        return account;
    }

    async _getProfileSafe(account) {
        try {
            return await Box.getProfile(account);
        } catch (e) {
            return null;
        }
    }

    async _getSpaceSafe(account) {
        try {
            return await Box.getSpace(account, NIFTY_FOOTY_SPACE);
        } catch (e) {
            return null;
        }
    }

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://niftyfootball.cards/league'
  2. Open console
  3. See error

Expected behavior Expect null or empty state for missing profiles without error

Screenshots image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Browser CHROME with MetaMask

Additional context Discussed on discord with team - happy to report more on discord

andygray avatar May 16 '19 08:05 andygray

@oed - not a huge deal but is there any way to sidestep these 404 errors that you know of? They're muddling up my console as well.

image

adamsoffer avatar Feb 17 '20 15:02 adamsoffer

@adamsoffer yeah, unfortunately it's browser behaviour to log all 404 errors so even if we catch them they still show up. We would need to make a breaking change to our apis to fix this.

oed avatar Feb 20 '20 12:02 oed

The error which is being logged does not break the functionality but it spams the console with a lot 404s.

The problem is that 3box-api is returning 404 HTTP status if it's unable to find the profile via address.

In order to make it better, the proposed solution is to return all the responses with 200 HTTP status and embed 3Box statuses inside the returned payload.

Since this doesn't affect the execution, we will reiterate this issue later. For now, there are filters which can clear the appearing 404s in the console. One of the solutions proposed for Chrome with filters:

  • https://stackoverflow.com/questions/14337351/can-i-prevent-the-chrome-developer-tools-console-from-logging-image-404-errors

simonovic86 avatar Jun 01 '20 12:06 simonovic86