(request: Request, message: string)
| 6201 | } |
| 6202 | |
| 6203 | export function resolveDebugMessage(request: Request, message: string): void { |
| 6204 | if (!__DEV__) { |
| 6205 | // These errors should never make it into a build so we don't need to encode them in codes.json |
| 6206 | // eslint-disable-next-line react-internal/prod-error-codes |
| 6207 | throw new Error( |
| 6208 | 'resolveDebugMessage should never be called in production mode. This is a bug in React.', |
| 6209 | ); |
| 6210 | } |
| 6211 | const deferredDebugObjects = request.deferredDebugObjects; |
| 6212 | if (deferredDebugObjects === null) { |
| 6213 | throw new Error( |
| 6214 | "resolveDebugMessage/closeDebugChannel should not be called for a Request that wasn't kept alive. This is a bug in React.", |
| 6215 | ); |
| 6216 | } |
| 6217 | if (message === '') { |
| 6218 | closeDebugChannel(request); |
| 6219 | return; |
| 6220 | } |
| 6221 | // This function lets the client ask for more data lazily through the debug channel. |
| 6222 | const command = message.charCodeAt(0); |
| 6223 | const ids = message.slice(2).split(',').map(fromHex); |
| 6224 | switch (command) { |
| 6225 | case 82 /* "R" */: |
| 6226 | // Release IDs |
| 6227 | for (let i = 0; i < ids.length; i++) { |
| 6228 | const id = ids[i]; |
| 6229 | const retainedValue = deferredDebugObjects.retained.get(id); |
| 6230 | if (retainedValue !== undefined) { |
| 6231 | // We're no longer blocked on this. We won't emit it. |
| 6232 | request.pendingDebugChunks--; |
| 6233 | deferredDebugObjects.retained.delete(id); |
| 6234 | deferredDebugObjects.existing.delete(retainedValue); |
| 6235 | enqueueFlush(request); |
| 6236 | } |
| 6237 | } |
| 6238 | break; |
| 6239 | case 81 /* "Q" */: |
| 6240 | // Query IDs |
| 6241 | for (let i = 0; i < ids.length; i++) { |
| 6242 | const id = ids[i]; |
| 6243 | const retainedValue = deferredDebugObjects.retained.get(id); |
| 6244 | if (retainedValue !== undefined) { |
| 6245 | // If we still have this object, and haven't emitted it before, emit it on the stream. |
| 6246 | const counter = {objectLimit: 10}; |
| 6247 | deferredDebugObjects.retained.delete(id); |
| 6248 | deferredDebugObjects.existing.delete(retainedValue); |
| 6249 | emitOutlinedDebugModelChunk(request, id, counter, retainedValue); |
| 6250 | enqueueFlush(request); |
| 6251 | } |
| 6252 | } |
| 6253 | break; |
| 6254 | case 80 /* "P" */: |
| 6255 | // Query Promise IDs |
| 6256 | for (let i = 0; i < ids.length; i++) { |
| 6257 | const id = ids[i]; |
| 6258 | const retainedValue = deferredDebugObjects.retained.get(id); |
| 6259 | if (retainedValue !== undefined) { |
| 6260 | // If we still have this Promise, and haven't emitted it before, wait for it |
no test coverage detected