(
request: Request,
id: number,
counter: {objectLimit: number},
model: ReactClientValue,
)
| 5101 | } |
| 5102 | |
| 5103 | function emitOutlinedDebugModelChunk( |
| 5104 | request: Request, |
| 5105 | id: number, |
| 5106 | counter: {objectLimit: number}, |
| 5107 | model: ReactClientValue, |
| 5108 | ): void { |
| 5109 | if (!__DEV__) { |
| 5110 | // These errors should never make it into a build so we don't need to encode them in codes.json |
| 5111 | // eslint-disable-next-line react-internal/prod-error-codes |
| 5112 | throw new Error( |
| 5113 | 'emitOutlinedDebugModel should never be called in production mode. This is a bug in React.', |
| 5114 | ); |
| 5115 | } |
| 5116 | |
| 5117 | if (typeof model === 'object' && model !== null) { |
| 5118 | // We can't limit outlined values. |
| 5119 | doNotLimit.add(model); |
| 5120 | } |
| 5121 | |
| 5122 | function replacer( |
| 5123 | this: |
| 5124 | | {+[key: string | number]: ReactClientValue} |
| 5125 | | $ReadOnlyArray<ReactClientValue>, |
| 5126 | parentPropertyName: string, |
| 5127 | value: ReactClientValue, |
| 5128 | ): ReactJSONValue { |
| 5129 | try { |
| 5130 | return renderDebugModel( |
| 5131 | request, |
| 5132 | counter, |
| 5133 | this, |
| 5134 | parentPropertyName, |
| 5135 | value, |
| 5136 | ); |
| 5137 | } catch (x) { |
| 5138 | return ( |
| 5139 | 'Unknown Value: React could not send it from the server.\n' + x.message |
| 5140 | ); |
| 5141 | } |
| 5142 | } |
| 5143 | |
| 5144 | const prevModelRoot = debugModelRoot; |
| 5145 | debugModelRoot = model; |
| 5146 | if (typeof model === 'object' && model !== null) { |
| 5147 | // Future references can refer to this object by id. |
| 5148 | request.writtenDebugObjects.set(model, serializeByValueID(id)); |
| 5149 | } |
| 5150 | let json: string; |
| 5151 | try { |
| 5152 | // $FlowFixMe[incompatible-cast] stringify can return null |
| 5153 | json = (stringify(model, replacer): string); |
| 5154 | } catch (x) { |
| 5155 | // $FlowFixMe[incompatible-cast] stringify can return null |
| 5156 | json = (stringify( |
| 5157 | 'Unknown Value: React could not send it from the server.\n' + x.message, |
| 5158 | ): string); |
| 5159 | } finally { |
| 5160 | debugModelRoot = prevModelRoot; |
no test coverage detected