Skip to content

Commit dd8d9ce

Browse files
committed
fix: small perf improvement
1 parent fa6c1ef commit dd8d9ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/core/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,18 @@ const runRequest = async (
180180
promises.push(timeoutPromise)
181181
}
182182
request.response = await Promise.race(promises)
183-
clearTimeout(timeoutID)
183+
if (timeoutID) {
184+
clearTimeout(timeoutID)
185+
}
184186

185187
plugin.afterHandler?.()
186188
await runMiddlewares(request, afterMiddlewares, plugin)
187189
}
188190
} catch (e) {
189191
// timeout should be aborted when errors happen in handler
190-
clearTimeout(timeoutID)
192+
if (timeoutID) {
193+
clearTimeout(timeoutID)
194+
}
191195

192196
// Reset response changes made by after stack before error thrown
193197
request.response = undefined

0 commit comments

Comments
 (0)