How to set a request timeout in the ClearRun SDK (timeoutMs)
Set hosted.timeoutMs when you create the client. The SDK aborts any request that takes longer. There is no timeout unless you set one.
Last updated
Steps
Set it
const client = createKernelClient({ hosted: { timeoutMs: 15000 }, });This example uses 15 seconds. Pick what fits your app.
Catch the abort
try { await client.score({ responseText }); } catch (err) { if (err.name === 'AbortError') { // timed out } }A timeout is an abort error, not a
HostedApiError.
createVerifyClient too
createVerifyClient({ timeoutMs: 10000 }) takes the same option.
Timeouts and credits
A timeout stops your side waiting. It does not cancel work ClearRun has already started, so the call may still be charged. Use the verdict id or Usage history to check.