timgit / pg-boss

Queueing jobs in Node.js using PostgreSQL like a boss
MIT License
1.73k stars 144 forks source link

Unable to set the output column on `work` method #393

Open felipeelias opened 1 year ago

felipeelias commented 1 year ago

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.

Gukirt007 commented 1 year ago

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 1 year ago

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

timgit commented 1 year ago

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