-
-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: "should have module" panic #9534
Comments
Can you provide a minimal reproduction? thank you |
Hello @jeffijoe, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by |
I'm trying to reproduce it minimally, but I think it needs to be a large enough codebase for the issue to manifest. I'll keep trying. |
@chenjiahan for more context, I am self-hosting the Rsbuild dev server for a Koa backend, would there be any problem with the following middleware (race conditions)? Or are there any betters APIs to generate the assets markup for rendering in a view? If any APIs here are unsafe to call in a server middleware, then that would help me narrow down how to reproduce it minimally. import type Koa from 'koa'
import koaConnect from 'koa-connect'
import { type AssetsMarkup, type ServerCallback } from '../lib/server.js'
import fs from 'node:fs'
import path from 'node:path'
export interface RsbuildMiddlewareOptions {
/**
* Method that allows the middleware to access the HTTP server
* when it becomes available.
*/
onServer: (callback: ServerCallback) => void
}
/**
* Runs the Rsbuild dev server (powered by Rspack, powered by Rust).
*
* @param options
*/
export function rsbuild(options: RsbuildMiddlewareOptions): Koa.Middleware {
const rsbuildPromise = import('@rsbuild/core').then(
async ({ createRsbuild, loadConfig }) => {
const rsbuildInstance = await createRsbuild({
rsbuildConfig: await loadConfig().then((c) => c.content),
})
const rsbuildDevServer = await rsbuildInstance.createDevServer({
runCompile: true,
})
options.onServer((server) => {
rsbuildDevServer.connectWebSocket({ server })
})
const wrappedDevMiddleware = koaConnect((req, res, next) =>
rsbuildDevServer.middlewares(req, res, next),
)
return {
wrappedDevMiddleware,
rsbuildInstance,
rsbuildDevServer,
}
},
)
return async function rsbuildMiddleware(ctx, next) {
const { wrappedDevMiddleware, rsbuildDevServer } = await rsbuildPromise
// Set the status to 200 in case the dev middleware is the last one
// to run. This is because it doesn't set the status for some reason.
ctx.status = 200
// Call the dev server middleware.
await wrappedDevMiddleware(ctx, async () => {
// Set it back just in case.
ctx.status = 404
// If we reach this point, the dev server middleware isn't
// serving an asset, so we can add asset info to the context.
const compilation = await rsbuildDevServer.environments.web
.getStats()
.then((s) => s.compilation)
const compilationAssets = compilation.getAssets()
if (!compilationAssets) {
throw new Error('Rsbuild did not return any assets.')
}
const jsAssets: string[] = []
const cssAssets: string[] = []
for (const asset of compilationAssets) {
try {
// Don't include lazy-loaded assets.
if (asset.name.includes('/async/')) {
continue
}
if (asset.name.endsWith('.css')) {
cssAssets.push(`<link rel="stylesheet" href="/${asset.name}">`)
continue
}
if (asset.name.endsWith('.js')) {
if ('info' in asset && asset.info.hotModuleReplacement) {
// Ignore HMR updates when generating the initial asset list.
continue
}
jsAssets.push(`<script defer src="/${asset.name}"></script>`)
}
} catch (err: unknown) {
console.error('Unable to process asset', asset, err)
}
}
// Makes the assets available to the subsequent `views` middleware.
ctx.state.devServerAssets = [...cssAssets, ...jsAssets].join('\n')
return next()
})
}
} |
@chenjiahan I may have made another observation - do you know if there would be any issue with running the app dev server and an Rsbuild Storybook simultaneously? For example, does the TS Checker rely on some shared state that may be namespaced based on the current working directory? I'm still testing this theory, but I noticed that I didn't observe the issue when I was only running my app dev server, but when I started the Storybook one alongside it, both of them crashed at the same time after I did a Git rebase. 🤔 |
System Info
System:
OS: macOS 15.3.1
CPU: (10) arm64 Apple M1 Max
Memory: 650.28 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node
npm: 10.8.1 - ~/.nvm/versions/node/v20.12.1/bin/npm
pnpm: 9.10.0 - ~/.nvm/versions/node/v20.12.1/bin/pnpm
Browsers:
Chrome: 133.0.6943.142
Safari: 18.3
Safari Technology Preview: 18.4
Details
The
ts-checker-rspack-plugin
crashes randomly when performing Git operations such as rebase, checkout, etc. I suspect it is due to multiple files changing concurrently. I originally opened this issue on the ts-checker-rspack-plugin repo, but was asked to open the issue here.Reproduce link
No response
Reproduce Steps
When running in dev/watch mode in a project with a few Git commits that affect multiple files, check out commits fast enough, and eventually, the plugin will crash.
The text was updated successfully, but these errors were encountered: