(
handlers: Array<RequestHandler>,
onUnhandledFrame: UnhandledFrameHandle,
resolutionContext?: NetworkFrameResolutionContext,
)
| 135 | } |
| 136 | |
| 137 | public async resolve( |
| 138 | handlers: Array<RequestHandler>, |
| 139 | onUnhandledFrame: UnhandledFrameHandle, |
| 140 | resolutionContext?: NetworkFrameResolutionContext, |
| 141 | ): Promise<boolean | null> { |
| 142 | const { id: requestId, request } = this.data |
| 143 | const requestCloneForLogs = resolutionContext?.quiet |
| 144 | ? null |
| 145 | : request.clone() |
| 146 | |
| 147 | this.events.emit(new RequestEvent('request:start', { requestId, request })) |
| 148 | |
| 149 | // Requests wrapped in explicit "bypass(request)". |
| 150 | if (shouldBypassRequest(request)) { |
| 151 | this.events.emit(new RequestEvent('request:end', { requestId, request })) |
| 152 | this.passthrough() |
| 153 | return null |
| 154 | } |
| 155 | |
| 156 | const [lookupError, lookupResult] = await until(() => { |
| 157 | return executeHandlers({ |
| 158 | requestId, |
| 159 | request, |
| 160 | handlers, |
| 161 | resolutionContext: { |
| 162 | baseUrl: resolutionContext?.baseUrl?.toString(), |
| 163 | quiet: resolutionContext?.quiet, |
| 164 | }, |
| 165 | }) |
| 166 | }) |
| 167 | |
| 168 | if (lookupError != null) { |
| 169 | if ( |
| 170 | !this.events.emit( |
| 171 | new UnhandledExceptionEvent('unhandledException', { |
| 172 | error: lookupError, |
| 173 | requestId, |
| 174 | request, |
| 175 | }), |
| 176 | ) |
| 177 | ) { |
| 178 | // Surface the error to the developer since they haven't handled it. |
| 179 | console.error(lookupError) |
| 180 | devUtils.error( |
| 181 | 'Encountered an unhandled exception during the handler lookup for "%s %s". Please see the original error above.', |
| 182 | request.method, |
| 183 | request.url, |
| 184 | ) |
| 185 | } |
| 186 | |
| 187 | this.errorWith(lookupError) |
| 188 | return null |
| 189 | } |
| 190 | |
| 191 | // No matching handlers. |
| 192 | if (lookupResult == null) { |
| 193 | this.events.emit( |
| 194 | new RequestEvent('request:unhandled', { |
searching dependent graphs…