fix(env): proxy directly to process.env instead of snapshotting#12822
Open
jerome-benoit wants to merge 17 commits intoanomalyco:devfrom
Open
fix(env): proxy directly to process.env instead of snapshotting#12822jerome-benoit wants to merge 17 commits intoanomalyco:devfrom
jerome-benoit wants to merge 17 commits intoanomalyco:devfrom
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
badedc7 to
4e8a1ef
Compare
ed0b5ac to
95a2dba
Compare
jerome-benoit
added a commit
to jerome-benoit/dotfiles
that referenced
this pull request
Mar 2, 2026
… and bun provider tracking Cherry-pick three upstream PRs: - anomalyco/opencode#14958: add thinking variant support for SAP AI provider - anomalyco/opencode#12822: remove Env namespace, use direct process.env access - anomalyco/opencode#10275: track provider packages with reference counting for cleanup
jerome-benoit
referenced
this pull request
Mar 11, 2026
Co-authored-by: Aiden Cline <[email protected]>
6f2e3fe to
e68d760
Compare
4c6de47 to
b4233fc
Compare
05c3cae to
1a59133
Compare
db4d5c0 to
290d33d
Compare
This was referenced Apr 25, 2026
b4a22d2 to
bf21d10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #22451
Type of change
What does this PR do?
The
Envservice was snapshottingprocess.envat init time viaInstanceState.make(() => Effect.succeed({ ...process.env })). This caused stale reads (Env.get()returned the init-time value, not the current one) and silentset()calls (only the internal copy was mutated, neverprocess.env).The fix replaces the
InstanceState-based snapshot with aLayer.succeedthat proxies directly toprocess.envviaEffect.sync:get(key)→Effect.sync(() => process.env[key])— live readall()→Effect.sync(() => ({ ...process.env }))— fresh shallow copy per call (prevents accidental mutation ofprocess.envvia the returned object)set(key, value)→Effect.sync(() => { process.env[key] = value })— writes toprocess.envdirectlyremove(key)→Effect.sync(() => { delete process.env[key] })— deletes fromprocess.envdirectlyThe
Env.Interfacecontract is unchanged — zero consumer modifications needed.Additionally:
provider.tsthat documented the now-fixed bugtest/preload.ts(AICORE_*,AWS_CONTAINER_*) to prevent host env leaking into testsHow did you verify your code works?
bun typecheckpasses across all 19 packagesenv.all()/env.get()consumers inprovider.ts,config.ts, andtool/registry.tsare read-only and unaffected by the change from snapshot to live proxypreload.ts,beforeEach/afterEach,try/finally, helper closures,Effect.acquireRelease,afterAll) all operate onprocess.envdirectly, independent ofEnv.ServiceChecklist