Skip to content

Apply optimization for unused actions (#69178)#4

Open
MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
pr_034_after
Open

Apply optimization for unused actions (#69178)#4
MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
pr_034_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_034


Note

Medium Risk
Touches webpack entry generation for Server Actions and changes what gets emitted into the server reference manifest; mistakes could break action availability at runtime, though the new test coverage reduces the risk.

Overview
Reduces server-reference-manifest.json bloat by tracking which server actions are actually imported per entry and runtime (node vs edge) in FlightClientEntryPlugin, then filtering the action list before creating action entries.

This introduces a second module-graph traversal to collect imported identifiers (including handling esm vs cjs semantics and preserving inline $$ACTION_ identifiers), and adds new production tests covering basic usage, shared modules, re-exports, mixed ESM/CJS imports, and edge runtime behavior.

Written by Cursor Bugbot for commit e951e89. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

) {
actions.delete(filePath)
}
}
Copy link

Choose a reason for hiding this comment

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

Unreachable else-if block contains dead code

Medium Severity

The else if (!containsAll) condition at line 974 can never evaluate to true. After line 967's if (!usedActionNames) continue, usedActionNames is guaranteed truthy. The preceding if (usedActionNames && !containsAll) at line 969 therefore simplifies to if (!containsAll). The else branch is only reached when containsAll is true, making the !containsAll check always false. This renders the actions.delete(filePath) call unreachable.

Fix in Cursor Fix in Web

// Collect used exported actions.
if (visitedModule.has(modResource) && actions) {
this.setUsedActionsInEntry(entryName, modResource, ids)
}
Copy link

Choose a reason for hiding this comment

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

First visit skips recording used action identifiers

High Severity

In collectActionsInDep, setUsedActionsInEntry is only called when visitedModule.has(modResource) is true (on revisit). On first visit to an action module, the imported identifiers (ids) are not recorded. When multiple components in the same entry import different actions from the same file, the first component's action identifiers are lost, potentially causing those actions to be incorrectly filtered out during tree-shaking.

Fix in Cursor Fix in Web

usedActions: {
node: {} as Record<string, Set<string>>,
edge: {} as Record<string, Set<string>>,
},
Copy link

Choose a reason for hiding this comment

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

Declared pluginState.usedActions is never used

Low Severity

The usedActions property added to pluginState at lines 80-83 is declared but never read or written anywhere in the code. The implementation uses the instance property this.usedActions instead. This dead code adds confusion and increases maintenance burden.

Fix in Cursor Fix in Web

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