Skip to content

fix(rsc): align export async function checks#1169

Merged
hi-ogawa merged 5 commits intovitejs:mainfrom
james-elicx:james/align-async-func
Apr 6, 2026
Merged

fix(rsc): align export async function checks#1169
hi-ogawa merged 5 commits intovitejs:mainfrom
james-elicx:james/align-async-func

Conversation

@james-elicx
Copy link
Copy Markdown
Contributor

Description

The wrap-export and proxy-export files were both checking async functions slightly differently. The proxy-export file's version was less permissive than the wrap-export one. This changes them to share the same logic (and adds class expressions as well at the same time).

I believe this was the cause of cloudflare/vinext#722 and should potentially fix it.

@james-elicx james-elicx changed the title fix: align export async function checks fix(rsc): align export async function checks Mar 31, 2026
@hi-ogawa hi-ogawa self-assigned this Apr 5, 2026
Copy link
Copy Markdown
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I move the util and unify the two test cases.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR unifies how wrap-export and proxy-export validate exported async functions in the RSC transform pipeline, making the checks consistent and more permissive where appropriate (including handling class expressions), which should address the reported mismatch behavior.

Changes:

  • Centralize rejectNonAsyncFunction validation into transforms/utils.ts and reuse it from both transforms.
  • Align proxy-export validation behavior with wrap-export (and add rejection for class expressions when enabled).
  • Move/expand the validation test coverage into a shared utils.test.ts that exercises both transforms.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/plugin-rsc/src/transforms/wrap-export.ts Removes local validation helper and delegates to shared validateNonAsyncFunction.
packages/plugin-rsc/src/transforms/wrap-export.test.ts Removes the now-redundant per-transform validation test.
packages/plugin-rsc/src/transforms/utils.ts Adds shared validateNonAsyncFunction implementation (including class expressions).
packages/plugin-rsc/src/transforms/utils.test.ts Adds consolidated tests verifying accepted/rejected patterns for both transforms.
packages/plugin-rsc/src/transforms/proxy-export.ts Replaces stricter bespoke validation with shared logic; validates variable initializers individually.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hi-ogawa hi-ogawa merged commit 14d8889 into vitejs:main Apr 6, 2026
21 checks passed
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.

3 participants