Skip to content

feat(defer): add options parameter with name field for debugging#25

Merged
uhyo merged 1 commit intomasterfrom
claude/defer-options-parameter-4a0xk
Jan 26, 2026
Merged

feat(defer): add options parameter with name field for debugging#25
uhyo merged 1 commit intomasterfrom
claude/defer-options-parameter-4a0xk

Conversation

@uhyo
Copy link
Owner

@uhyo uhyo commented Jan 26, 2026

Add a DeferOptions interface as the second parameter to the defer function.
The optional name field helps with debugging RSC payloads:

  • Development: name is included in the payload file name
  • Production: name is logged when the payload file is emitted

Add a DeferOptions interface as the second parameter to the defer function.
The optional name field helps with debugging RSC payloads:
- Development: name is included in the payload file name
- Production: name is logged when the payload file is emitted
Copy link

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 adds an optional DeferOptions parameter to the defer() function, introducing a name field for debugging purposes. The name is included in development payload file names (via sanitized ID) and logged during production builds when files are emitted.

Changes:

  • Added DeferOptions interface with optional name field for debugging
  • Added sanitizeName() function to sanitize names for use in file paths
  • Updated defer() function to accept options parameter and incorporate name into payload IDs
  • Threaded the name field through the entire processing pipeline from registration through build output

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/static/src/rsc/defer.tsx Added DeferOptions interface, sanitizeName function, and updated defer() to accept options; modified DeferEntry and DeferRegistry to store and propagate name field
packages/static/src/entries/server.ts Exported DeferOptions type for public API consumption
packages/static/src/build/rscProcessor.ts Updated ProcessedComponent and RawComponent interfaces to include name field; modified processRscComponents to track and propagate names
packages/static/src/build/buildApp.ts Updated writeFileNormal to accept and log optional name parameter when writing deferred component files

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

Comment on lines +202 to +205
const sanitizedName = name ? sanitizeName(name) : undefined;
const rawId = sanitizedName
? `${sanitizedName}-${crypto.randomUUID()}`
: crypto.randomUUID();
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

The sanitizeName function can return an empty string when the input contains only non-alphanumeric characters (e.g., "!!!" or "###"). This would result in a rawId starting with a hyphen like "-abc-123-uuid", which may cause issues with file paths or module IDs. Consider adding a check to handle this edge case, such as falling back to undefined when the sanitized result is empty.

Copilot uses AI. Check for mistakes.
@uhyo uhyo merged commit 0a737b5 into master Jan 26, 2026
7 checks passed
@uhyo uhyo deleted the claude/defer-options-parameter-4a0xk branch January 26, 2026 11:14
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