pg-boss icon indicating copy to clipboard operation
pg-boss copied to clipboard

Unable to set the output column on `work` method

Open felipeelias opened this issue 2 years ago • 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.

felipeelias avatar May 16 '23 14:05 felipeelias

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

Gukirt007 avatar May 20 '23 03:05 Gukirt007

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

timgit avatar Jun 22 '23 01:06 timgit

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

timgit avatar Jul 02 '23 22:07 timgit