Updated the official JavaScript and TypeScript SDK

The SDK now explains connection failures such as "ECONNRESET" and can retry them automatically.

Changelog1 min read

Written by

Dmytro Krasun

Published on

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 ConnectionError that 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 (lastElapsedMs and totalElapsedMs).
  • Automatic retries. Set the maxRetries client 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.

Read more product updates

New features, bug fixes, and optimizations...

View all product updates
Transfer organization ownership

Transfer organization ownership

From today, you can transfer organization ownership to another user.

Read more

1 min read

Improved clip and full page validation

Improved clip and full page validation

ScreenshotOne now rejects requests that combine clipping options with full page screenshots before rendering starts.

Read more

1 min read

Change your billing email

Change your billing email

Use a dedicated address for invoices and other billing emails without changing your sign-in email.

Read more

1 min read

Automate website screenshots

Exhaustive documentation, ready SDKs, no-code tools, and other automation to help you render website screenshots and outsource all the boring work related to that to us.