timgit/pg-boss

Unable to set the output column on `work` method

felipeelias opened this issue · 3 comments

Hi!

In the 8.x version I was able to set the result of the job and store in the table. This seems to have been removed in 9.x.

Minimal example with Typescript:

import PgBoss from "pg-boss";

const boss = new PgBoss("...");

await boss.work<{ foo: string }>("email-queue", async (job) => {
  console.log(job.data.foo);
  return "ok"; // previously this was stored in the `output` column
});

Typescript complains with the following error:

Argument of type '(job: Job<{ foo: string; }>) => Promise<string>' is not assignable to parameter of type 'WorkHandler<{ foo: string; }>'.
  Type 'Promise<string>' is not assignable to type 'Promise<void>'.
    Type 'string' is not assignable to type 'void'.

Wondering if that change is intended and if there is another way to set the output in the table.

Hii, i am facing the similar issue and after researching i found out that its best for now to keep using 8.x ( previous stable version you were using).
Thanks

timgit commented

This was not intended. It's an issue in the type definitions

timgit commented

Please try this again in 9.0.2 and see if it's resolved