(event, requestId)
| 121 | }) |
| 122 | |
| 123 | async function handleRequest(event, requestId) { |
| 124 | const client = await resolveMainClient(event) |
| 125 | const response = await getResponse(event, client, requestId) |
| 126 | |
| 127 | // Send back the response clone for the "response:*" life-cycle events. |
| 128 | // Ensure MSW is active and ready to handle the message, otherwise |
| 129 | // this message will pend indefinitely. |
| 130 | if (client && activeClientIds.has(client.id)) { |
| 131 | ;(async function () { |
| 132 | const responseClone = response.clone() |
| 133 | |
| 134 | sendToClient( |
| 135 | client, |
| 136 | { |
| 137 | type: 'RESPONSE', |
| 138 | payload: { |
| 139 | requestId, |
| 140 | isMockedResponse: IS_MOCKED_RESPONSE in response, |
| 141 | type: responseClone.type, |
| 142 | status: responseClone.status, |
| 143 | statusText: responseClone.statusText, |
| 144 | body: responseClone.body, |
| 145 | headers: Object.fromEntries(responseClone.headers.entries()), |
| 146 | }, |
| 147 | }, |
| 148 | [responseClone.body], |
| 149 | ) |
| 150 | })() |
| 151 | } |
| 152 | |
| 153 | return response |
| 154 | } |
| 155 | |
| 156 | // Resolve the main client for the given event. |
| 157 | // Client that issues a request doesn't necessarily equal the client |
no test coverage detected