Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function properties of a job data are not available in the worker callback #1159

Closed
Sin13 opened this issue Mar 27, 2022 · 1 comment
Closed

Comments

@Sin13
Copy link
Contributor

Sin13 commented Mar 27, 2022

it looks like we cant have functions as properties in a job data. they are in fact there when i create them, as you can see in the log below (its called the fillerFunction):

Screenshot from 2022-03-27 11-36-49

but when i log the job again in the worker callback, the fillerFunction property is nowhere to be seen:

Screenshot from 2022-03-27 11-42-05

i create the jobs like this:

      const flow = await flowProducer.add({
        name: 'certificate setup',
        queueName,
        children: [
          {
            name: 'activate Certificate',
            data: {
                type: 'activate',
                description: 'certificate activation',
                url: '',
                method: 'post',
               collection: 'ssl_tls_certificate_v2',
               filter: {
                // some code
               },
               details: {
                // some code
               },
               fillerFunction: function () {
                 console.log('testing');
               },
               cool: 'ok its cool',
             },
            queueName,
          },
        ],
      });

      console.log('🚀 ~ file: setup.ts ~ line 46 ~ setup ~ flow', flow.children![0]);

and the worker code is like this:

const worker = new Worker(
    queueName,
    async (job) => {
      console.log('🚀 ~ file: generateWorker.ts ~ line 33 ~ job.data', job.data);
      if (job.data.fillerFunction) job.data.fillerFunction();
      const result = await handleJob(job.data);
      return result;
    },
    {
      connection: config.redisConnection,
    },
  );
@Sin13
Copy link
Contributor Author

Sin13 commented Mar 27, 2022

my bad! a function cant just be serialized and deserialized this easily.

@Sin13 Sin13 closed this as completed Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant