Automattic / Automattic/kue

Not able to pass classes and objects via job's data

Open
#903 1 comment 0 reactions 0 assignees View on GitHub
Question
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

I want to pass an object created before creating the job, and a class to the job's data. That job is generic and would be working on multiple classes depending on properties passed to the job.
I do not want to hard code the class names in my job processing.
But the job process that I have written, does not receive class and method values, the whole key-value pair is missing from job.data. All other simple key-value pairs are present.

Example:

```
const job = this.queue.create(jobType, {
title: 'Some title for '+ source,
identifier: userIdentifier,
source: source,
graphLoader: this.getGraphLoader(source), // This is a class
redis: this.redis // This is an object
}).backoff({delay: graphConstants.graphPopulationRetryDelay,
type: 'exponential'}).
```

What my job.data includes:

```
{ title: 'Some title for abcd',
identifier: '79398',
source: 'abcd',
redis:
{ options: { host: 'xx.xx.xx.xxx', port: 6379, db: '14', sep: '--' }} }
```

As is visible, the class key-value pair is missing. And the object's key value pair simply is an object with the object's attribute, not the actual object!

How do I find a solution for this?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the queue.create call shown in the issue and trace how job data is serialized before it reaches the worker's job.data. Compare the handling of the class and object values with the simple key-value fields, then verify the intended behavior with a focused reproduction; done means the behavior or its supported usage is documented and confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.