cloudflare / cloudflare/vinext

RSC moduleMap undefined on first request: Cannot read properties of undefined (reading 'moduleMap')

Open
#185 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

## Bug

After a successful `vinext deploy`, the deployed Worker crashes on every request with:

```
TypeError: Cannot read properties of undefined (reading 'moduleMap')
```

HTTP response: `500 error code: 1101` (Worker threw an unhandled exception)

## Environment

- vinext: 0.0.13
- React: 19.2.0
- Next.js: 15.2.x
- Deployment: Cloudflare Workers (via `vinext deploy` or `wrangler deploy --config dist/server/wrangler.json`)

## Steps to reproduce

1. `vinext build` completes successfully
2. `wrangler deploy` using the generated `dist/server/wrangler.json`
3. Visit the deployed URL — Worker immediately returns 500/1101
4. The error is `Cannot read properties of undefined (reading 'moduleMap')` from the RSC layer

## Root cause (suspected)

The RSC client manifest / module map is not being correctly initialized or passed between the RSC server layer and the SSR edge environment. The `dist/server/` worker attempts to use the module map before it's populated.

## Workaround

Use Next.js `output: 'export'` (static export) and deploy the `out/` directory as a static asset Worker:

```toml
# wrangler.toml
name = "my-app"
compatibility_date = "2026-02-27"
workers_dev = true

[assets]
directory = "./out"
```

This bypasses RSC/SSR entirely and works reliably, though it sacrifices server-side rendering.

## Expected behavior

The deployed Worker should serve the app successfully without RSC initialization errors.

Contributor guide

Open the contributing guide

Research direction

Inspect the generated dist/server/ worker and the RSC client manifest or module-map handoff first. Reproduce with vinext build, then deploy using dist/server/wrangler.json and trace the first request through the RSC layer. Done means the deployed Worker serves the app without the moduleMap exception or a 500/1101 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, react, typescript
Domain
backend, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.