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

Make CTX.do more defensive #36

Closed
nathanclevenger opened this issue Oct 10, 2022 · 1 comment
Closed

Make CTX.do more defensive #36

nathanclevenger opened this issue Oct 10, 2022 · 1 comment
Assignees

Comments

@nathanclevenger
Copy link
Member

We can't afford for anything to make ctx.do stop working because it breaks so many things now.

So, we need to make a few changes:

  1. We need to declare all of the variables as let x = undefined at the top outside a try/catch block
  2. We need to hydrate all of the objects, in progressive levels of complexity/risk, wrapped with a try/catch block
  3. We need to ensure that we don't assume any object/field exists ... even including and especially fields like cf.[whatever] because those can break, and in fact in certain situations (like Workers for Platforms), the cf object is never hydrated
  4. The response to JSON needs to be outside the try/catch block, so if there is an exception, we are still able to respond with the basics
  5. Errors in ctx.do should be logged to Sentry and/or Slack as emergency alerts (see Log any Caught Exceptions on ctx.do to Slack as high-priority alert #35)

There are some other refactors we'll probably need to do, like moving the user object construction into separate above variables instead of the on-demand construction that is currently happening.

@sam-lippert
Copy link
Contributor

Completed in 1df6e06 (minus #35, tracked separately)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants