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

Site CRASH: "load more posts" in EMPTY search result #1420

Closed
huyxgit opened this issue Nov 19, 2020 · 8 comments · Fixed by #1742
Closed

Site CRASH: "load more posts" in EMPTY search result #1420

huyxgit opened this issue Nov 19, 2020 · 8 comments · Fixed by #1742
Assignees
Labels
type: bug Something isn't working

Comments

@huyxgit
Copy link

huyxgit commented Nov 19, 2020

When user try to search with keywords that returns no result, now it showing "load more posts" instead of showing something like "no result". When click on "load more posts" button, the web crash in ~20-30 secs.

This one maybe relate to #1415, or sth else.

@huyxgit huyxgit added the type: bug Something isn't working label Nov 19, 2020
@huyxgit huyxgit changed the title Site CRASH when click "load more posts" in EMPTY search result Site CRASH: "load more posts" in EMPTY search result Nov 19, 2020
@humphd
Copy link
Contributor

humphd commented Nov 19, 2020

Nice catch @VIETNAMEZE. Did I see a bug somewhere else to remove the "Load More Posts" button completely? cc @PedroFonsecaDEV.

@humphd
Copy link
Contributor

humphd commented Nov 19, 2020

Steps To Reproduce:

  1. Go to Search
  2. Select Post as the filter
  3. Type in paul sinj (or any text that doesn't exist in a post)
  4. Click the LOAD MORE POSTS button
  5. Open the DevTools Network tab
  6. Watch it load page after page of non-results
  7. Eventually it hits page 999, and on page 1000 returns a 400 and renders null (white screen)

Screen Shot 2020-11-19 at 6 50 46 PM

cc @joelazwar

@joelazwar
Copy link
Contributor

Hmm yeah we need to code something to detect when it has all the results or else itll keep fetching at the bottom of the page. Working on something for #1408 that also might fix this

@DukeManh
Copy link
Contributor

DukeManh commented Feb 14, 2021

I think I know what the cause is, useSWRInfinite returns an array of pages where data[0] is an array of posts on the first page. To determine if the search returns nothing we should check for empty data[0] rather than data because ([ [] ]) is truthy.

@DukeManh
Copy link
Contributor

I filed #1739, quick fix for this.

@PedroFonsecaDEV
Copy link
Contributor

I filed #1739, quick fix for this.

Thanks @DukeManh.
Please feel free to join us on Slack! You are more than welcome!

@DukeManh
Copy link
Contributor

I'm very happy to contribute. I already joined the server.

DukeManh added a commit to DukeManh/telescope that referenced this issue Feb 14, 2021
@DukeManh
Copy link
Contributor

The new properly rebased PR is #1742

DukeManh added a commit to DukeManh/telescope that referenced this issue Feb 15, 2021
DukeManh added a commit to DukeManh/telescope that referenced this issue Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants