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:
We need to declare all of the variables as let x = undefined at the top outside a try/catch block
We need to hydrate all of the objects, in progressive levels of complexity/risk, wrapped with a try/catch block
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
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
Errors in ctx.do should be logged to Sentry and/or Slack as emergency alerts (see #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.
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:
let x = undefined
at the top outside a try/catch blockcf.[whatever]
because those can break, and in fact in certain situations (like Workers for Platforms), thecf
object is never hydratedThere 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.