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

[Issue #1823]: Fix prod FE error #1824

Merged
merged 4 commits into from
Apr 25, 2024
Merged

[Issue #1823]: Fix prod FE error #1824

merged 4 commits into from
Apr 25, 2024

Conversation

rylew1
Copy link
Contributor

@rylew1 rylew1 commented Apr 24, 2024

Summary

Fixes #1823

Time to review: 5 min

Changes proposed

  • Add error handling when we have invalid JSON returned (when API is up but not endpoints are enabled)

image

Error we can simulate locally (same thing on prod):

Throwing error:  Not Found 404 {
  query: '',
  status: Set(0) {},
  fundingInstrument: Set(0) {},
  eligibility: Set(0) {},
  agency: Set(0) {},
  category: Set(0) {},
  sortby: null,
  page: 1,
  actionType: 'initialLoad'
}
Error fetching opportunities: T [Error]: {"type":"NotFoundError","searchInputs":{"query":"","status":[],"fundingInstrument":[],"eligibility":[],"agency":[],"category":[],"sortby":null,"page":1,"actionType":"initialLoad"},"message":"Unknown Error","status":404}
    at L (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:93101)
    at /Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92757
    at H.sendRequest (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92783)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async H.request (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92406)
    at async H.searchOpportunities (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:93571)
    at async V.fetchOpportunities (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:94560)
    at async z (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:152457)
T [Error]: {"type":"NotFoundError","searchInputs":{"query":"","status":[],"fundingInstrument":[],"eligibility":[],"agency":[],"category":[],"sortby":null,"page":1,"actionType":"initialLoad"},"message":"Unknown Error","status":404}
    at L (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:93101)
    at /Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92757
    at H.sendRequest (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92783)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async H.request (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:92406)
    at async H.searchOpportunities (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:93571)
    at async V.fetchOpportunities (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:94560)
    at async z (/Users/ryan/Desktop/simpler-grants-gov/frontend/.next/server/app/search/page.js:18:152457)
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: '1277226382'
}

andycochran
andycochran previously approved these changes Apr 24, 2024
Comment on lines +225 to +226
console.log("Throwing error: ", message, status_code, searchInputs);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this left in by mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - I want it to show in server logs. But there's still some problems with this PR so I need to commit some different changes @andycochran

};
}

parsedErrorData = JSON.parse(error.message) as ParsedError;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't set the var to falsey?

@rylew1 rylew1 requested a review from andycochran April 25, 2024 04:56
@rylew1
Copy link
Contributor Author

rylew1 commented Apr 25, 2024

I had thought we might be able to just pass the error status code and type to the client error boundary component (error.tsx) - but it appears in a built version of the site it won't even let you pass the error message properly (or at least I need to do some further investigation as to why)

This PR unblocks analytics a bit but there's still a lingering question:

  • Why can't the built site make proper calls to the API?

Copy link
Collaborator

@coilysiren coilysiren left a comment

Choose a reason for hiding this comment

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

Approving again since it looks like Andy originally approved earlier

@rylew1 rylew1 merged commit 4a6a855 into main Apr 25, 2024
9 checks passed
@rylew1 rylew1 deleted the rylew/1823-fix-prod-fe-error branch April 25, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[Task]: Fix prod FE error
3 participants