Version 1.1.25 of the official JavaScript and TypeScript SDK makes connection failures easier to understand and recover from.
A request can fail on the network between your server and the API, for example with ECONNRESET when a proxy, NAT gateway, or firewall closes the connection. Before, the SDK passed on the raw error. Now:
- Clear connection errors. The SDK throws a
ConnectionErrorthat says whether the connection broke before the API responded or while the screenshot was downloading, and what usually causes it.- It includes the error code, and the HTTP status when the response had already started.
- It says how many attempts were made, and how long after the last and the first attempt the connection failed (
lastElapsedMsandtotalElapsedMs).
- Automatic retries. Set the
maxRetriesclient option to retry connection resets with exponential backoff. It’s 0 by default.
import * as screenshotone from "screenshotone-api-sdk";
const client = new screenshotone.Client("<access key>", "<secret key>", { maxRetries: 3,});A retry sends the request again. If the API had already finished the first request, the retry renders the screenshot again and counts toward your quota again, unless the result is served from the cache.
Connection resets are more likely when many requests start at once. If you take screenshots in large batches, limit how many requests run at the same time.
Existing error handling keeps working: error.code is still ECONNRESET for connection resets, and API errors are still APIError.
To upgrade, run npm install screenshotone-api-sdk@latest. See the JavaScript and TypeScript examples and the SDK README for error handling.
If you have any questions or suggestions, please contact support@screenshotone.com.


