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 }) => {
plugins: [
new rspack.DefinePlugin({
'typeof window': JSON.stringify('undefined'),
'process.env.NODE_ENV': JSON.stringify(
dev ? 'development' : 'production'
),
// This bundle is specifically for dev server, so NODE_ENV should always be 'development'
// 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({
banner: '/* Bundled dev server - reduces module loading overhead */',
......
......@@ -263,7 +263,7 @@ export function isBytecodeCacheEnabled(): boolean {
export function clearBytecodeCache(): void {
const cacheDir = getCacheDir()
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 })
}
}
......@@ -44,13 +44,18 @@ describe('server-side dev errors', () => {
// TODO: update to ensure this frame is ignored properly by default
function stripInternalHandler(output) {
return output
.replace(/.*at async handler .*next-route-loader.*/, '')
.replace(/.*at async handleResponse.*/, '')
.replace(/.*at async doRender \(.*/, '')
.split(/\n/)
.filter((item) => !!item.trim())
.join('\n')
return (
output
.replace(/.*at async handler .*next-route-loader.*/, '')
.replace(/.*at async handleResponse.*/, '')
.replace(/.*at async doRender \(.*/, '')
// Strip bundled dev-server internal frames
.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 () => {
......
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