Is it safe to use `env.HYPERDRIVE.
Is it safe to use
env.HYPERDRIVE.connectionString
in the global context?6 Replies
The env is provided via the fetch parameters, so not sure if that's what your looking for. See sample code https://developers.cloudflare.com/hyperdrive/get-started/#write-a-worker
Cloudflare Docs
Get started · Hyperdrive
Hyperdrive accelerates access to your existing databases from Cloudflare Workers, making even single-region databases feel globally distributed.
I'm thinking of caching the postgresql js client in the global scope.
That connectionString is not a secret, it is generated based on your binding and will only be usable by the account that owns the binding. I would say yes, it is safe to post on Reddit if you want to.
Will it change though?
Ah. That's a good question, sorry I missed the implication there.
I'm not an expert on the runtime internals, so best I can say is "it might".
General recommendation is to not cache anything globally that relies on env
I don’t think it can change without a full isolate reload right now, but I don’t think we provide any guarantees it will stay that way