#Cloudflare worker context persists between requests?

16 messages · Page 1 of 1 (latest)

fallen depot
#

I don’t think Context even should be console loggable, but it’s API-surface shouldn’t change between requests

#

And also, there shouldn’t ever be extras there either

carmine epoch
fallen depot
carmine epoch
#

My context has fields like "auth_user" which should be different between requests if requests are done by different users

fallen depot
#

Must be some code doing weird stuff with the context then

#

As in, you aren’t supposed to modify it at all

carmine epoch
#

Interesting! Is it anywhere in the docs that context should not be modified by any route handlers? I thought that context just carries request context, including things that we want to keep there for duration of request.

fallen depot
carmine epoch
#

Got it. Will look for it in the docs. If context is not to be modified in this way, I would hope the docs would clearly state.

fallen depot
#

So it is an unintended issue

carmine epoch
#

Where would you keep data between different handlers that might be processing the same request? (e.g. the first handler authenticates, second one has business logic conditioned on authentication results). First handler's gotta pass state to second handler.

fallen depot
carmine epoch
safe raft