pln-planning-tools / Starmap

Roadmap Planning Tool
https://starmap.site
Other
20 stars 8 forks source link

bug: fetchErrors from SW should not degrade user experience #350

Closed SgtPooki closed 1 year ago

SgtPooki commented 1 year ago

Requests are currently throwing a lot of fetchErrors.

I suspect this might be related to our github tokens being expired or exhausted.

screenshots

image

image

### Tasks
- [x] Ensure SW-fetch errors that are due to invalid cache, but result in a successful non-cache-request, are silent
- [x] Ensure SW-fetch errors that are due to invalid cache, but result in a successful non-cache-request, remove/delete/override the invalid cache entry.
- [x] Ensure we are not caching failed requests.. we should only be caching successful requests
SgtPooki commented 1 year ago

The keys seem to be valid.

I am not sure what is happening here.

SgtPooki commented 1 year ago

after clearing the site data, unregistering the service worker, and reloading the page (then repeating those steps), I am able to get things working properly, consistently, again.

we need to add some tests and better handling in the SW to forward the request if the SW fails for some reason.

juliangruber commented 1 year ago

Clearing site data was the missing step for me, now it's working again 👍

momack2 commented 1 year ago

Can we resolve this problem at the root? I don't think clearing site data is an effective solution - I need this roadmap to work (https://starmap.site/roadmap/github.com/protocol/engres/issues/9#detail), but right now it doesnt load most of the items due to this error.

CleanShot 2023-04-13 at 01 29 47@2x

vs all the milestones listed here:

CleanShot 2023-04-13 at 01 30 57@2x
SgtPooki commented 1 year ago

@momack2 clearing the site data should get you to a place where these issues do not happen anymore, but we will use this issue to silence fetch errors from the service worker so that users only get a slower experience instead of a list of errors.

SgtPooki commented 1 year ago

Vercel log errors:

2023-04-24T20:59:25.151Z    undefined   INFO    info  - Loaded env from /var/task/.env.production
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/var/task/.next/server/pages/api/pendingChild.js:227:23)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:366:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:741:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:252:36)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:365:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:303:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9)
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/var/task/.next/server/pages/api/pendingChild.js:227:23)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:366:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:741:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:252:36)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:365:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:303:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9)
RequestId: 67debd54-4ddd-41e0-af2f-041872b35d42 Error: Runtime exited with error: exit status 1
Runtime.ExitError
2023-04-24T20:59:17.047Z    undefined   INFO    info  - Loaded env from /var/task/.env.production
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/var/task/.next/server/pages/api/pendingChild.js:227:23)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:366:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:741:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:252:36)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:365:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:303:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9)
SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at handler (/var/task/.next/server/pages/api/pendingChild.js:227:23)
    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:366:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:481:9)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:741:37)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:252:36)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:365:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:303:20)
    at async Server.module.exports (/var/task/___next_launcher.cjs:29:9)
RequestId: 3a5c040f-97d5-4a38-af0e-008712e8d10f Error: Runtime exited with error: exit status 1
Runtime.ExitError

It seems like the problem was that pendingChild on the backend was never updated to decode parentJson. The update to use vercel cache (and GET requests) that required sending parentJson as a query parameter (which had to be encoded with encodeURIComponent to be a valid GET query), wasn't updated to run decodeURIComponent prior to JSON parsing.

SgtPooki commented 1 year ago

Will confirm this is fixed on starmap.site before leaving this resolved. I will re-open if I notice any issues.

SgtPooki commented 1 year ago

starmap.site is currently returning successes when refreshing without cache (cmd+R) and x-vercel-cache: MISS, but failing when x-vercel-cache: HIT at https://starmap.site/api/pendingChild?owner=drand&repo=roadmap&issue_number=12&parentJson=%7B%22labels%22%3A%5B%5D%2C%22completion_rate%22%3A0%2C%22due_date%22%3A%222023-06-30%22%2C%22html_url%22%3A%22https%3A%2F%2Fgithub.com%2Fprotocol%2Fengres%2Fissues%2F8%22%2C%22group%22%3A%22Children%3A%22%2C%22title%22%3A%22EngRes%20Theme%3A%20Critical%20System%20Stewardship%20%26%20Growth%22%2C%22state%22%3A%22open%22%2C%22node_id%22%3A%22I_kwDOIiXv285gZJEN%22%2C%22parent%22%3A%7B%22state%22%3A%22open%22%2C%22group%22%3A%22root%22%2C%22title%22%3A%22EngRes%20Theme-Based%202023%20Roadmap%22%2C%22html_url%22%3A%22https%3A%2F%2Fgithub.com%2Fprotocol%2Fengres%2Fissues%2F9%22%2C%22labels%22%3A%5B%5D%2C%22node_id%22%3A%22I_kwDOIiXv285gZJpY%22%2C%22completion_rate%22%3A0%2C%22due_date%22%3A%222023-06-30%22%2C%22description%22%3A%22%22%7D%2C%22children%22%3A%5B%5D%2C%22description%22%3A%22%22%7D

Should clear when vercel/browsers/users invalidate their cache, because the vercel hosted domain seems to load fine without CMD+R https://starmaps-git-main-ipfs-ignite.vercel.app/api/pendingChild?owner=drand&repo=roadmap&issue_number=12&parentJson=%7B%22labels%22%3A%5B%5D%2C%22completion_rate%22%3A0%2C%22due_date%22%3A%222023-06-30%22%2C%22html_url%22%3A%22https%3A%2F%2Fgithub.com%2Fprotocol%2Fengres%2Fissues%2F8%22%2C%22group%22%3A%22Children%3A%22%2C%22title%22%3A%22EngRes%20Theme%3A%20Critical%20System%20Stewardship%20%26%20Growth%22%2C%22state%22%3A%22open%22%2C%22node_id%22%3A%22I_kwDOIiXv285gZJEN%22%2C%22parent%22%3A%7B%22state%22%3A%22open%22%2C%22group%22%3A%22root%22%2C%22title%22%3A%22EngRes%20Theme-Based%202023%20Roadmap%22%2C%22html_url%22%3A%22https%3A%2F%2Fgithub.com%2Fprotocol%2Fengres%2Fissues%2F9%22%2C%22labels%22%3A%5B%5D%2C%22node_id%22%3A%22I_kwDOIiXv285gZJpY%22%2C%22completion_rate%22%3A0%2C%22due_date%22%3A%222023-06-30%22%2C%22description%22%3A%22%22%7D%2C%22children%22%3A%5B%5D%2C%22description%22%3A%22%22%7D


clearing all site data seems to allow things to work on starmap.site without CMD+R loading

SgtPooki commented 1 year ago

Everything seems to be working smoothly now. If you encounter any further issues, please don't hesitate to reach out to us for assistance.