Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaptured server errors on 404 #114

Closed
luisherranz opened this issue Jun 5, 2019 · 12 comments
Closed

Uncaptured server errors on 404 #114

luisherranz opened this issue Jun 5, 2019 · 12 comments
Labels
bug Something isn't working priority: low
Projects
Milestone

Comments

@luisherranz
Copy link
Member

It looks like right now the server reports 404's on the console. Sometimes like this (http://localhost:3000/category/performance/):

An error ocurred fetching '/category/mobile-performance/':
 Error: Entity of from endpoint 'categories' with slug 'mobile-performance' not found
    at Api.getIdBySlug (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/api.ts:9:227)
    at process._tickCallback (internal/process/next_tick.js:68:7)

and sometimes like this (http://localhost:3000/page/8):

An error ocurred fetching '/':
 TypeError: Cannot destructure property `id` of 'undefined' or 'null'.
    at entityList.map (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/populate.ts:6:47)
    at Array.map (<anonymous>)
    at populate (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/populate.ts:6:43)
    at process._tickCallback (internal/process/next_tick.js:68:7)
@luisherranz luisherranz added the bug Something isn't working label Jun 5, 2019
@luisherranz luisherranz added this to the 1.0 Release milestone Jun 5, 2019
@luisherranz luisherranz added this to To do in 1.0 Release Jun 5, 2019
@orballo
Copy link
Collaborator

orballo commented Jun 17, 2019

Fixed in #122

@orballo orballo closed this as completed Jun 17, 2019
1.0 Release automation moved this from To do to Done Jun 17, 2019
@luisherranz luisherranz reopened this Jul 18, 2019
@luisherranz
Copy link
Member Author

This is still happening in the current version. Both errors:

http://localhost:3000/category/asdf/:

Error: Entity of from endpoint 'categories' with slug 'asdf' not found
    at Api.getIdBySlug (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/api.ts:9:227)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

and http://localhost:3000/asdf:

TypeError: Cannot destructure property `id` of 'undefined' or 'null'.
    at attachmentHandler (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/attachment.ts:4:135)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

@DAreRodz could you please document here why is this happening and what can we do about it?

@SantosGuillamot
Copy link
Member

It also happens in these urls, both with the same error:

http://localhost:3000/category/chastening
http://localhost:3000/category/disinfection

TypeError: Cannot read property 'name' of undefined
      at List (webpack-internal:///./packages/mars-theme/src/components/list/list.js:10:271)
      at runAsReaction (webpack-internal:///./node_modules/@frontity/connect/src/reactionRunner.js:16:45)
      at reaction (webpack-internal:///./node_modules/@frontity/connect/src/observer.js:7:131)
      at props (webpack-internal:///./node_modules/@frontity/connect/src/connect.js:18:8)
      at processChild (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:452:2364)
      at resolve (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:451:122)
      at ReactDOMServerRenderer.render (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:487:855)
      at ReactDOMServerRenderer.read (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:487:55)
      at renderToString (webpack-internal:///./node_modules/react-dom/cjs/react-dom-server.node.development.js:520:116)
      at app.use (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:47:243)

@orballo
Copy link
Collaborator

orballo commented Jul 28, 2019

It looks like the cause is this console.log

Introduced in this commit about a month ago.

@luisherranz
Copy link
Member Author

That's the cause of the console log but we need to know what's making it throw in the first place. Both:

TypeError: Cannot destructure property `id` of 'undefined' or 'null'.
// and
TypeError: Cannot read property 'name' of undefined

@DAreRodz could you please document here why is this happening and what can we do about it?

@DAreRodz
Copy link
Member

Those errors must be in handlers. I'm checking which of them need to be fixed.

@DAreRodz
Copy link
Member

First case: Cannot destructure property `id` of 'undefined' or 'null'

Attachment and Page handlers could throw that error when the attachment or page is not found.

Also, Author, Date, Taxonomy and PostArchive handlers should throw a descriptive error when a page out of range is fetched, but are not implemented correctly, returning the error above. They all fail at this line in populate.ts.

The reason is that api.get returns the following error object and populate doesn't know how to handle it:

{
    "code": "rest_post_invalid_page_number",
    "message": "The page number requested is larger than the number of pages available.",
    "data": {
        "status": 400
    }
}

@DAreRodz
Copy link
Member

Second case: Cannot read property 'name' of undefined

This error is happening at this line in the List component. The problem here is the limit of 10 categories maximum when embedding. Taxonomy handler was assuming that the category being fetched would appear in the embedded categories of the posts, and this is not the case. The category is not being populated and List fails when it renders.

In the case of chastening category (id: 74), it contains just one post with 64 categories, and that post has the id 74 at the index 10 inside categories array.

@orballo
Copy link
Collaborator

orballo commented Jul 29, 2019

But I think those errors are expected by design. It's a try catch that when the error is thrown in the handler sets is404: true, unless any of the URL failing should work instead, is not actually a bug.

@DAreRodz
Copy link
Member

Yeah, well, most cases are expected to return with a 404 page but not all of them (for example, when the server returns a 500 error). And it would also be nice if the error messages were more descriptive for developers.

We have to think of a good way to handle errors.

@orballo
Copy link
Collaborator

orballo commented Jul 29, 2019

Yeah, that makes sense.

@luisherranz
Copy link
Member Author

Closed as this doesn't seem to be an issue anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low
Projects
No open projects
1.0 Release
  
Done
Development

No branches or pull requests

4 participants