A visibility timeout is an Amazon SQS setting that temporarily hides a received message while a worker processes it. The worker must finish the task and delete the message before the timeout expires; otherwise, SQS makes the message available again. section 14.2.5
Configure the timeout as part of the worker’s receive operation:
- Set VisibilityTimeout in seconds. A practical starting point is roughly four times the average processing time. section 14.2.5
- Process the received message within that period. section 14.2.5
- Delete the message with its ReceiptHandle after successful processing; deletion acknowledges completion. section 14.2.5
URL-to-PNG worker
A Node.js worker receives one SQS message with VisibilityTimeout set to 120 seconds, uses Puppeteer to capture the requested website, uploads the PNG to S3, and then deletes the message. If the work exceeds 120 seconds, the message becomes visible and may be processed again. section 14.2.5 section 14.2.6
Visibility timeout supports at-least-once processing rather than exactly-once delivery. Make processing idempotent where possible, and use a dead-letter queue when repeated failures would otherwise leave a message retrying indefinitely. section 14.2.6 section 16.3.4
Listing 14.5 worker.js: Receiving a message from the queue
const fs = require('fs');
const AWS = require('aws-sdk');
const puppeteer = require('puppeteer');
const config = require('./config.json');
const sqs = new AWS.SQS();
const s3 = new AWS.S3();
async function receive() {
const result = await sqs.receiveMessage({ #1
QueueUrl: config.QueueUrl,
MaxNumberOfMessages: 1, #2
VisibilityTimeout: 120, #3
WaitTimeSeconds: 10 #4
}).promise();
if (result.Messages) { #5
return result.Messages[0] #6
} else {
return null;
}
};
The worker listing shows VisibilityTimeout alongside batch size and long polling, making the receive configuration concrete. section 14.2.5

