fix(javascript): invalidate Electron reads after direct eval (#7053)

This commit is contained in:
Wenyu Chiou authored and GitHub committed 2026-10-25 11:29:45 +08:00
1 parent 69a2faa120
commit 26e155987f
6 files changed
+308 -5

No files matched your search

@@ -6,6 +6,8 @@ import { createSemanticModuleInterop } from "./javascriptModuleInterop.js";
import {
semanticEffectTiming,
semanticBindingEffectFollowsCapture,
semanticBindingEffectFollowsRead,
semanticReadPrecedesEffectWithinActivation,
} from "./javascriptSemanticMutationInitializers.js";
import {
isUnshadowedGlobal,
@@ -134,6 +136,17 @@ export const semanticBindingMayHaveOpaqueEffect = (
read,
effect,
state.parentsByNode,
) &&
// Rebinding a freshly initialized local is activation-specific;
// mutations to the referenced object may persist across calls.
!(
kind === "binding" &&
semanticBindingEffectFollowsRead(
binding,
read,
effect,
state.parentsByNode,
)
))
)
return true;
@@ -186,7 +199,13 @@ export const semanticOpaqueNameMayHaveChanged = (
(binding === undefined ||
resolveSemanticBindingState(state, effect, binding.name)
?.bindingId === binding.bindingId) &&
semanticEffectTiming(read, effect, state) !== "after",
semanticEffectTiming(read, effect, state) !== "after" &&
// A sloppy-eval name belongs to this activation, not a prior call.
!semanticReadPrecedesEffectWithinActivation(
read,
effect,
state.parentsByNode,
),
)
)
return true;