Hi again, it looks like
await qstash.messages.delete(oldProgramMessage.messageId);
produces the following error, despite the message actually being cancelled.
SyntaxError: Unexpected token A in JSON at position 0
web:dev: at JSON.parse (<anonymous>)
web:dev: at parseJSONFromBytes (node:internal/deps/undici/undici:6498:19)
web:dev: at successSteps (node:internal/deps/undici/undici:6472:27)
web:dev: at node:internal/deps/undici/undici:1145:60
web:dev: at node:internal/process/task_queues:140:7
web:dev: at AsyncResource.runInAsyncScope (node:async_hooks:204:9)
web:dev: at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
web:dev: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
the oldProgramMessage is fetched like this:
const oldProgramMessage = await qstash.messages.get(program.nextRunJobId);
Here is what I do as a work-around:
try {
const oldProgramMessage = await qstash.messages.get(program.nextRunJobId);
try {
await qstash.messages.delete(oldProgramMessage.messageId);
} catch (error) {
if (error.message.includes("Unexpected token A in JSON at position 0")) {
// ignore // For some reason the qstash api client throws this error, even though the message is cancelled
} else {
// in case it was unable to delete
console.log("error message", error);
console.log("failed to delete old message", oldProgramMessage);
}
}
} catch (error) {
console.log("failed to get old message", program.nextRunJobId);
// in case the message was not found
}
This seems like an issue in an older version of the sdk. I was unable to reproduce the behavior in the last version. Feel free to open the issue if you can reproduce the issue.
Hi again, it looks like
await qstash.messages.delete(oldProgramMessage.messageId);
produces the following error, despite the message actually being cancelled.
the oldProgramMessage is fetched like this:
const oldProgramMessage = await qstash.messages.get(program.nextRunJobId);
Here is what I do as a work-around: