@@ -324,14 +324,8 @@ const inflate = (
324
324
case TypeIds . Error : {
325
325
const d = data as unknown [ ] ;
326
326
target . message = d [ 0 ] ;
327
- const second = d [ 1 ] ;
328
- if ( second && Array . isArray ( second ) ) {
329
- for ( let i = 0 ; i < second . length ; i ++ ) {
330
- target [ second [ i ++ ] ] = second [ i ] ;
331
- }
332
- target . stack = d [ 2 ] ;
333
- } else {
334
- target . stack = second ;
327
+ for ( let i = 1 ; i < d . length ; i += 2 ) {
328
+ target [ d [ i ] as string ] = d [ i + 1 ] ;
335
329
}
336
330
break ;
337
331
}
@@ -818,7 +812,7 @@ export const createSerializationContext = (
818
812
) {
819
813
// ignore
820
814
} else if ( obj instanceof Error ) {
821
- discoveredValues . push ( ... Object . values ( obj ) ) ;
815
+ discoveredValues . push ( obj . message , ... Object . values ( obj ) , isDev && obj . stack ) ;
822
816
} else if ( isStore ( obj ) ) {
823
817
const target = getStoreTarget ( obj ) ! ;
824
818
const effects = getStoreHandler ( obj ) ! . $effects$ ;
@@ -1268,13 +1262,11 @@ function serialize(serializationContext: SerializationContext): void {
1268
1262
output ( TypeIds . Regex , value . toString ( ) ) ;
1269
1263
} else if ( value instanceof Error ) {
1270
1264
const out : any [ ] = [ value . message ] ;
1271
- const extraProps = Object . entries ( value ) . flat ( ) ;
1272
- if ( extraProps . length ) {
1273
- out . push ( extraProps ) ;
1274
- }
1265
+ // flatten gives us the right output
1266
+ out . push ( ...Object . entries ( value ) . flat ( ) ) ;
1275
1267
/// In production we don't want to leak the stack trace.
1276
1268
if ( isDev ) {
1277
- out . push ( value . stack ) ;
1269
+ out . push ( 'stack' , value . stack ) ;
1278
1270
}
1279
1271
output ( TypeIds . Error , out ) ;
1280
1272
} else if ( $isSsrNode$ ( value ) ) {
0 commit comments