Clarification on global env and isolate re-use

Based on this change on 2025-01-15, is it fair to say that this guidance in the docs is outdated? Specifically the guidance that calls out risks around polluting global scope:
"When you deploy a change to your Worker, and only change its bindings (i.e. you don't change the Worker's code), Cloudflare may reuse existing isolates that are already running your Worker... As a result, you must be careful when "polluting" global scope with derivatives of your bindings."
In other words, I'm looking to confirm that since Jan 15, you can now use import { env } from "cloudflare:workers"; and know that if the env vars change you'll get those changes?
4 Replies
Walshy
Walshy4mo ago
That quote is still correct And yes, when you update your env vars, the env will of course be updated.
Michael
MichaelOP4mo ago
I guess what I meant was– you can use env from "cloudflare:workers" at initialization time and be confident that if you change the env secrets, the worker version will have changed and as a result your global scope will be re-initialized?
Michael
MichaelOP4mo ago
Perhaps a more concrete question: is this example of a global scope pollution in the docs still an issue after Jan 15th given that "The runtime will no longer reuse isolates across worker versions even if the code happens to be identical."?
No description
Michael
MichaelOP3mo ago
@Walshy | DevPlat EE just wanted to follow up on this

Did you find this page helpful?