| 992 | } |
| 993 | |
| 994 | function pushHaltedAwaitOnComponentStack( |
| 995 | task: Task, |
| 996 | debugInfo: void | null | ReactDebugInfo, |
| 997 | ): void { |
| 998 | if (!__DEV__) { |
| 999 | // eslint-disable-next-line react-internal/prod-error-codes |
| 1000 | throw new Error( |
| 1001 | 'pushHaltedAwaitOnComponentStack should never be called in production. This is a bug in React.', |
| 1002 | ); |
| 1003 | } |
| 1004 | if (debugInfo != null) { |
| 1005 | for (let i = debugInfo.length - 1; i >= 0; i--) { |
| 1006 | const info = debugInfo[i]; |
| 1007 | if (typeof info.name === 'string') { |
| 1008 | // This is a Server Component. Any awaits in previous Server Components already resolved. |
| 1009 | break; |
| 1010 | } |
| 1011 | if (typeof info.time === 'number') { |
| 1012 | // This had an end time. Any awaits before this must have already resolved. |
| 1013 | break; |
| 1014 | } |
| 1015 | if (info.awaited != null) { |
| 1016 | const asyncInfo: ReactAsyncInfo = (info: any); |
| 1017 | const bestStack = |
| 1018 | asyncInfo.debugStack == null ? asyncInfo.awaited : asyncInfo; |
| 1019 | if (bestStack.debugStack !== undefined) { |
| 1020 | task.componentStack = { |
| 1021 | parent: task.componentStack, |
| 1022 | type: asyncInfo, |
| 1023 | owner: bestStack.owner, |
| 1024 | stack: bestStack.debugStack, |
| 1025 | }; |
| 1026 | task.debugTask = (bestStack.debugTask: any); |
| 1027 | break; |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | function pushServerComponentStack( |
| 1035 | task: Task, |