Skip to content

Durable use cache: optimize env var existence checks - #98504

Merged
mischnic merged 7 commits into
canaryfrom
mischnic/env-var-existence-e2e
Sep 11, 2026
Merged

Durable use cache: optimize env var existence checks#98504
mischnic merged 7 commits into
canaryfrom
mischnic/env-var-existence-e2e

Conversation

@mischnic

@mischnic mischnic commented Sep 10, 2026

Copy link
Copy Markdown
Member

We now separately track code that accesses non-inlined env vars at runtime in two categories

  • (existing) actual reads, the full value is accessed
  • (new) only unset/falsy/truthy is read at runtime

For the second case, we only need to invalidate use-cache functions when the given env var transitioned betwen unset/falsy/truthy. But transitioning between two different truthy values doesn't caused invalidation.

mischnic commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 4068e2f

@mischnic mischnic changed the title add test for next/image use cache dura Sep 10, 2026
@mischnic mischnic changed the title use cache dura Durable use cache: optimize env var existence checks Sep 10, 2026
@mischnic
mischnic marked this pull request as ready for review September 10, 2026 14:00
@mischnic
mischnic changed the base branch from mischnic/env-var-existence to graphite-base/98504 September 10, 2026 14:01
@mischnic
mischnic changed the base branch from graphite-base/98504 to canary September 10, 2026 14:02
@mischnic
mischnic force-pushed the mischnic/env-var-existence-e2e branch from a8d415f to bd20198 Compare September 10, 2026 14:03
@mischnic
mischnic requested review from a team and unstubbable September 10, 2026 14:20
@mischnic
mischnic force-pushed the mischnic/env-var-existence-e2e branch from dfb8475 to e7699fe Compare September 10, 2026 16:54
prop: prop_value,
ast_path: as_parent_path_in(self.arena, ast_path),
span: member_expr.span(),
in_truthiness_context: is_in_boolean_context(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could defer this test to effect processing, this would be slightly more efficient since we would mostly not need to walk the AST path

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we can't. I first wanted to do it like this.

in the effect processing stage, we have [AstParentKind], which is only the type of the AST node, not the actual AST node. So here, we can only tell if this is anyFn(process.env.FOO) and not if it's actually Boolean(process.env.FOO)

Comment thread turbopack/crates/turbopack-ecmascript/src/references/mod.rs Outdated
@mischnic
mischnic force-pushed the mischnic/env-var-existence-e2e branch from e7699fe to 4068e2f Compare September 11, 2026 17:18
@mischnic
mischnic merged commit f41441a into canary Sep 11, 2026
415 of 425 checks passed
@mischnic
mischnic deleted the mischnic/env-var-existence-e2e branch September 11, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants