@@ -92,7 +92,7 @@ describe('ReactDOMFizzServer', () => {
92
92
function expectErrors ( errorsArr , toBeDevArr , toBeProdArr ) {
93
93
const mappedErrows = errorsArr . map ( ( { error, errorInfo} ) => {
94
94
const stack = errorInfo && errorInfo . componentStack ;
95
- const digest = errorInfo && errorInfo . digest ;
95
+ const digest = error . digest ;
96
96
if ( stack ) {
97
97
return [ error . message , digest , normalizeCodeLocInfo ( stack ) ] ;
98
98
} else if ( digest ) {
@@ -3230,6 +3230,47 @@ describe('ReactDOMFizzServer', () => {
3230
3230
) ;
3231
3231
} ) ;
3232
3232
3233
+ it ( 'warns in dev if you access digest from errorInfo in onRecoverableError' , async ( ) => {
3234
+ await act ( async ( ) => {
3235
+ const { pipe} = ReactDOMFizzServer . renderToPipeableStream (
3236
+ < div >
3237
+ < Suspense fallback = { 'loading...' } >
3238
+ < AsyncText text = { 'hello' } />
3239
+ </ Suspense >
3240
+ </ div > ,
3241
+ {
3242
+ onError ( error ) {
3243
+ return 'a digest' ;
3244
+ } ,
3245
+ } ,
3246
+ ) ;
3247
+ rejectText ( 'hello' ) ;
3248
+ pipe ( writable ) ;
3249
+ } ) ;
3250
+ expect ( getVisibleChildren ( container ) ) . toEqual ( < div > loading...</ div > ) ;
3251
+
3252
+ ReactDOMClient . hydrateRoot (
3253
+ container ,
3254
+ < div >
3255
+ < Suspense fallback = { 'loading...' } > hello</ Suspense >
3256
+ </ div > ,
3257
+ {
3258
+ onRecoverableError ( error , errorInfo ) {
3259
+ expect ( ( ) => {
3260
+ expect ( error . digest ) . toBe ( 'a digest' ) ;
3261
+ expect ( errorInfo . digest ) . toBe ( 'a digest' ) ;
3262
+ } ) . toErrorDev (
3263
+ 'Warning: You are accessing "digest" from the errorInfo object passed to onRecoverableError.' +
3264
+ ' This property is deprecated and will be removed in a future version of React.' +
3265
+ ' To access the digest of an Error look for this property on the Error instance itself.' ,
3266
+ { withoutStack : true } ,
3267
+ ) ;
3268
+ } ,
3269
+ } ,
3270
+ ) ;
3271
+ expect ( Scheduler ) . toFlushWithoutYielding ( ) ;
3272
+ } ) ;
3273
+
3233
3274
describe ( 'error escaping' , ( ) => {
3234
3275
it ( 'escapes error hash, message, and component stack values in directly flushed errors (html escaping)' , async ( ) => {
3235
3276
window . __outlet = { } ;
0 commit comments