Commit 37e6ad6 1 parent eccc180 commit 37e6ad6 Copy full SHA for 37e6ad6
File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/react " : patch
3
+ ---
4
+
5
+ warn and resolve null for invalid deferred data result to avoid unexpected hanging
Original file line number Diff line number Diff line change @@ -997,16 +997,22 @@ export function Scripts(props: ScriptProps) {
997
997
JSON . stringify ( toSerialize )
998
998
) } )`;
999
999
} else {
1000
- if ( typeof trackedPromise . _data === "undefined" ) {
1001
- throw new Error (
1002
- `The deferred data for ${ key } was not resolved, did you forget to return data from a deferred promise?`
1000
+ let data = trackedPromise . _data ;
1001
+ if ( typeof data === "undefined" ) {
1002
+ console . error (
1003
+ `Deferred data for ${ routeId } ${ key } resolved to undefined, defaulting to null.`
1003
1004
) ;
1005
+ data = null ;
1006
+ }
1007
+ let serializedData = "null" ;
1008
+ try {
1009
+ serializedData = JSON . stringify ( data ) ;
1010
+ } catch ( error ) {
1011
+ console . error ( error ) ;
1004
1012
}
1005
1013
return `${ JSON . stringify (
1006
1014
key
1007
- ) } :__remixContext.p(${ escapeHtml (
1008
- JSON . stringify ( trackedPromise . _data )
1009
- ) } )`;
1015
+ ) } :__remixContext.p(${ escapeHtml ( serializedData ) } )`;
1010
1016
}
1011
1017
}
1012
1018
} )
You can’t perform that action at this time.
0 commit comments