Skip to content

Fix: css in next/dynamic component in edge runtime (#64382)#1

Open
MitchLewis930 wants to merge 1 commit intopr_031_beforefrom
pr_031_after
Open

Fix: css in next/dynamic component in edge runtime (#64382)#1
MitchLewis930 wants to merge 1 commit intopr_031_beforefrom
pr_031_after

Conversation

@MitchLewis930
Copy link

PR_031

### What

Wrap async local storage for all edge runtime routes in adapter 

Basically fixed the case reported in [this
tweet](https://x.com/keegandonley/status/1778538456458854880)

### Why

We're relying on the ALS for dynamic css preloading but we didn't wrap
the ALS for request handlers for edge. So if you have CSS imports in
`next/dynamic` in edge runtime it would break.

Closes NEXT-3085
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 01:01
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 fixes an issue where CSS was not properly loading in next/dynamic components when using the edge runtime. The fix ensures that the request async storage context is available during CSS preloading in edge runtime environments.

Changes:

  • Updated CSS preloading logic to properly invoke getExpectedRequestStore with a caller argument
  • Wrapped edge runtime handler execution with RequestAsyncStorageWrapper to provide request context
  • Added test coverage for edge runtime dynamic CSS loading

Reviewed changes

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

File Description
test/e2e/app-dir/dynamic-css/index.test.ts Added test case to verify CSS loads correctly in edge runtime
test/e2e/app-dir/dynamic-css/app/ssr/edge/page.js Created new test page that uses edge runtime
packages/next/src/shared/lib/lazy-dynamic/preload-css.tsx Fixed CSS preloading to pass caller argument to getExpectedRequestStore
packages/next/src/server/web/adapter.ts Wrapped handler execution with request async storage context

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

`window.getComputedStyle(document.querySelector('.text')).color`
)
).toBe('rgb(255, 0, 0)')
// Default border width, which is not effected by bar.css that is not loaded in /ssr
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'effected' to 'affected'.

Copilot uses AI. Check for mistakes.
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