Commit 1a9b0f6 1 parent 0631549 commit 1a9b0f6 Copy full SHA for 1a9b0f6
File tree 1 file changed +11
-8
lines changed
packages/next/src/server/dev
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,24 @@ import * as Log from '../../build/output/log'
3
3
4
4
export function logAppDirError ( err : any ) {
5
5
if ( isError ( err ) && err ?. stack ) {
6
- const filteredStack = err . stack
7
- . split ( '\n' )
8
- . map ( ( line : string ) =>
9
- // Remove 'webpack-internal:' noise from the path
10
- line . replace ( / ( w e b p a c k - i n t e r n a l : \/ \/ \/ | f i l e : \/ \/ ) ( \( .* \) \/ ) ? / , '' )
11
- )
6
+ const cleanedStack = err . stack . split ( '\n' ) . map ( ( line : string ) =>
7
+ // Remove 'webpack-internal:' noise from the path
8
+ line . replace ( / ( w e b p a c k - i n t e r n a l : \/ \/ \/ | f i l e : \/ \/ ) ( \( .* \) \/ ) ? / , '' )
9
+ )
10
+ const filteredStack = cleanedStack
12
11
// Only display stack frames from the user's code
13
12
. filter (
14
13
( line : string ) =>
15
14
! / n e x t [ \\ / ] d i s t [ \\ / ] c o m p i l e d / . test ( line ) &&
16
15
! / n o d e _ m o d u l e s [ \\ / ] / . test ( line ) &&
17
16
! / n o d e : i n t e r n a l [ \\ / ] / . test ( line )
18
17
)
19
- . join ( '\n' )
20
- Log . error ( filteredStack )
18
+ if ( filteredStack . length === 1 ) {
19
+ // This is an error that happened outside of user code, keep full stack
20
+ Log . error ( `Internal error: ${ cleanedStack . join ( '\n' ) } ` )
21
+ } else {
22
+ Log . error ( filteredStack . join ( '\n' ) )
23
+ }
21
24
if ( typeof ( err as any ) . digest !== 'undefined' ) {
22
25
console . error ( `digest: ${ JSON . stringify ( ( err as any ) . digest ) } ` )
23
26
}
You can’t perform that action at this time.
0 commit comments