Skip to main content

Debug Logs

To debug the logs, first you need to understand the different states a task can be in.

Lifecycle of a Task

When you publish a message, for each destination a new task is created. To understand the lifecycle of each task, we'll look at the following chart:

Either you or a previously setup schedule will publish a message and a new task will be created. Depending on the delay (if you set any), the task will be planned for immediate execution or for later.

When a task is ready for execution, it will be become active and a delivery to your API is attempted.

If you API responds with a status code between 200 - 299, the task is considered successful and will be marked as Delivered.

Otherwise the task is being retried if there are any retries left and the task goes back to planned. If all retries are exhausted, the task has failed. Failed tasks are considered to be undeliverable and there is probably a problem with your API.

Console

Head over to the Upstash Console and go to the Logs tab, where you can see all your tasks.

Example

Here is a task fetched from https://qstash.upstash.io/v1/tasks

curl  https://qstash.upstash.io/v1/tasks -H "Authorization: Bearer <QSTASH_TOKEN>"
[
{
"taskId": "tsk_6CapFF3iiREAm5WfiBHEffTQTaLa",
"messageId": "msg_7EuyMgzec87XXVYwBXyB57u7x8Qx",
"state": "delivered",
"maxRetry": 5,
"retried": 1,
"lastErrorAt": 1657880211101,
"url": "https://your.api/notify",
"logs": [
{
"time": 1657904218830,
"state": "delivered",
// ...
},
{
"time": 1657904218072,
"state": "active",
// ...
},
{
"time": 1657882188578,
"state": "planned",
"nextDeliveryAt": 1657904214578
// ...,
},
{
"time": 1657880211101,
"error": "HTTP status 500",
"state": "error",
// ...
},
{
"time": 1657880210009,
"state": "active",
// ...
},
{
"time": 1657880210012,
"state": "planned",
"nextDeliveryAt": 1657880210009
// ...,
},
{
"time": 1657880209199,
"state": "created",
// ...
}
]
},
{ ... }
]

The logs are ordered in reverse chronological order, so the lowest log is the first one. As you can see, the task was created and the first delivery attempt has failed. After a delay, a second attempt was made and succeeded.