Commit 055db66b authored by Jimmy Lai's avatar Jimmy Lai

fix: update tests for bundled dev server stack traces

- Fix NODE_ENV to always be 'development' in bundled dev server
- Update edge-runtime-dynamic-code tests to check stack frames separately
- Update server-side-dev-errors to strip bundled dev-server frames
- Fix prettier formatting in bytecode-cache.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
parent ea51e6c4
...@@ -202,9 +202,9 @@ module.exports = ({ dev }) => { ...@@ -202,9 +202,9 @@ module.exports = ({ dev }) => {
plugins: [ plugins: [
new rspack.DefinePlugin({ new rspack.DefinePlugin({
'typeof window': JSON.stringify('undefined'), 'typeof window': JSON.stringify('undefined'),
'process.env.NODE_ENV': JSON.stringify( // This bundle is specifically for dev server, so NODE_ENV should always be 'development'
dev ? 'development' : 'production' // We don't use runtime NODE_ENV because some code paths check it at module load time
), 'process.env.NODE_ENV': JSON.stringify('development'),
}), }),
new rspack.BannerPlugin({ new rspack.BannerPlugin({
banner: '/* Bundled dev server - reduces module loading overhead */', banner: '/* Bundled dev server - reduces module loading overhead */',
......
...@@ -263,7 +263,7 @@ export function isBytecodeCacheEnabled(): boolean { ...@@ -263,7 +263,7 @@ export function isBytecodeCacheEnabled(): boolean {
export function clearBytecodeCache(): void { export function clearBytecodeCache(): void {
const cacheDir = getCacheDir() const cacheDir = getCacheDir()
if (existsSync(cacheDir)) { if (existsSync(cacheDir)) {
const { rmSync } = (require('fs') as typeof import('fs')) const { rmSync } = require('fs') as typeof import('fs')
rmSync(cacheDir, { recursive: true, force: true }) rmSync(cacheDir, { recursive: true, force: true })
} }
} }
...@@ -44,13 +44,18 @@ describe('server-side dev errors', () => { ...@@ -44,13 +44,18 @@ describe('server-side dev errors', () => {
// TODO: update to ensure this frame is ignored properly by default // TODO: update to ensure this frame is ignored properly by default
function stripInternalHandler(output) { function stripInternalHandler(output) {
return output return (
.replace(/.*at async handler .*next-route-loader.*/, '') output
.replace(/.*at async handleResponse.*/, '') .replace(/.*at async handler .*next-route-loader.*/, '')
.replace(/.*at async doRender \(.*/, '') .replace(/.*at async handleResponse.*/, '')
.split(/\n/) .replace(/.*at async doRender \(.*/, '')
.filter((item) => !!item.trim()) // Strip bundled dev-server internal frames
.join('\n') .replace(/.*at.*dev-server\/start-server\.js.*/g, '')
.replace(/.*at.*compiled\/dev-server.*/g, '')
.split(/\n/)
.filter((item) => !!item.trim())
.join('\n')
)
} }
it('should show server-side error for gsp page correctly', async () => { it('should show server-side error for gsp page correctly', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment