File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/react-client/src Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,27 @@ ReactPromise.prototype.then = function <T>(
266266 initializeModuleChunk ( chunk ) ;
267267 break ;
268268 }
269+ if ( __DEV__ && enableAsyncDebugInfo ) {
270+ // Because only native Promises get picked up when we're awaiting we need to wrap
271+ // this in a native Promise in DEV. This means that these callbacks are no longer sync
272+ // but the lazy initialization is still sync and the .value can be inspected after,
273+ // allowing it to be read synchronously anyway.
274+ const resolveCallback = resolve ;
275+ const rejectCallback = reject ;
276+ const wrapperPromise : Promise < T > = new Promise((res, rej) => {
277+ resolve = value => {
278+ // $FlowFixMe
279+ wrapperPromise . _debugInfo = this . _debugInfo ;
280+ res ( value ) ;
281+ } ;
282+ reject = reason => {
283+ // $FlowFixMe
284+ wrapperPromise . _debugInfo = this . _debugInfo ;
285+ rej ( reason ) ;
286+ } ;
287+ } ) ;
288+ wrapperPromise . then ( resolveCallback , rejectCallback ) ;
289+ }
269290 // The status might have changed after initialization.
270291 switch ( chunk . status ) {
271292 case INITIALIZED :
You can’t perform that action at this time.
0 commit comments