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

Cannot do job.update when job runs in separate process #1279

Closed
Gappa88 opened this issue Apr 12, 2019 · 6 comments · Fixed by #1716
Closed

Cannot do job.update when job runs in separate process #1279

Gappa88 opened this issue Apr 12, 2019 · 6 comments · Fixed by #1716

Comments

@Gappa88
Copy link

Gappa88 commented Apr 12, 2019

Description

I have changed the queue processor from a normal process to a separate process and now I cannot update a job anymore.
It throws the following error:
(node:7068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: job.update is not a function

Minimal, Working Test code to reproduce the issue.

// master.js

const Bull = require('bull');
const queue = new Bull("html_pusher", { redis: { "port": port, "host": "ip", "db": 0, "showFriendlyErrorStack": true, "password": "pwd" } });

const proc = require('./child.js');
queue.process(1, proc);
// child.js
module.exports = proc;

async function proc(job, done) {
  console.log(`HI JOB ${job.id}`);
  console.log(job);
  job.data.foo = 'bar';
  await job.update(job.data);
  return done();
}

when I convert the processor call to a separate process the job.update throws the error

// master.js

const Bull = require('bull');
const queue = new Bull("html_pusher", { redis: { "port": port, "host": "ip", "db": 0, "showFriendlyErrorStack": true, "password": "pwd" } });

queue.process(__dirname + "/child.js");

Bull version

3.4.8

Additional information

This is the content of job when processor is within the master process:

Job {
  opts:
   { attempts: 1,
     delay: 0,
     timestamp: 1555080724183,
     backoff: undefined },
  name: '__default__',
  queue:
   Queue {
     name: 'html_pusher',
     token: '641dc8a5-7722-4015-a464-06c268685617',
     keyPrefix: 'bull',
     clients: [ [Object], [Object], [Object] ],
     _initializing: Promise { undefined },
     handlers: { __default__: [AsyncFunction: bound proc] },
     processing: [ [Object] ],
     retrieving: 0,
     drained: false,
     settings:
      { lockDuration: 30000,
        stalledInterval: 30000,
        maxStalledCount: 1,
        guardInterval: 5000,
        retryProcessDelay: 5000,
        drainDelay: 5,
        backoffStrategies: {},
        lockRenewTime: 15000 },
     _events: { error: [Function] },
     _eventsCount: 1,
     timers: TimerManager { idle: false, listeners: [], timers: [Object] },
     moveUnlockedJobsToWait: [Function: bound ],
     processJob: [Function: bound ],
     getJobFromId: [Function: bound ],
     keys:
      { '': 'bull:html_pusher:',
        active: 'bull:html_pusher:active',
        wait: 'bull:html_pusher:wait',
        waiting: 'bull:html_pusher:waiting',
        paused: 'bull:html_pusher:paused',
        resumed: 'bull:html_pusher:resumed',
        'meta-paused': 'bull:html_pusher:meta-paused',
        id: 'bull:html_pusher:id',
        delayed: 'bull:html_pusher:delayed',
        priority: 'bull:html_pusher:priority',
        'stalled-check': 'bull:html_pusher:stalled-check',
        completed: 'bull:html_pusher:completed',
        failed: 'bull:html_pusher:failed',
        stalled: 'bull:html_pusher:stalled',
        repeat: 'bull:html_pusher:repeat',
        limiter: 'bull:html_pusher:limiter',
        drained: 'bull:html_pusher:drained',
        progress: 'bull:html_pusher:progress' },
     delayedTimestamp: 1.7976931348623157e+308,
     _initializingProcess: Promise { undefined },
     errorRetryTimer: {},
     registeredEvents: { delayed: [Object] },
     guardianTimer:
      Timeout {
        _called: true,
        _idleTimeout: 5000,
        _idlePrev: [Object],
        _idleNext: [Object],
        _idleStart: 30565,
        _onTimeout: [Function],
        _timerArgs: undefined,
        _repeat: 5000,
        _destroyed: false,
        [Symbol(asyncId)]: 116,
        [Symbol(triggerAsyncId)]: 0 },
     moveUnlockedJobsToWaitInterval:
      Timeout {
        _called: true,
        _idleTimeout: 30000,
        _idlePrev: [Object],
        _idleNext: [Object],
        _idleStart: 30650,
        _onTimeout: [Function: bound ],
        _timerArgs: undefined,
        _repeat: 30000,
        _destroyed: false,
        [Symbol(asyncId)]: 135,
        [Symbol(triggerAsyncId)]: 0 } },
  data:
   {
... my data ...
},
  _progress: 0,
  delay: 0,
  timestamp: 1555080724183,
  stacktrace: [],
  returnvalue: null,
  attemptsMade: 0,
  toKey: [Function: wrapper],
  id: '6604614',
  processedOn: 1555080725310,
  failedReason: undefined }

This is the content of job when job runs in a separate process:

{ id: '6604006',
  name: '__default__',
  data:
   { 
.... my data ....
  },
opts: { attempts: 1, delay: 0, timestamp: 1555080466092 },
progress: [Function],
  delay: 0,
  timestamp: 1555080466092,
  attemptsMade: 0,
  stacktrace: [],
  returnvalue: null,
  finishedOn: null,
  processedOn: 1555080467236 }

It seems that when the job is in a separate process some properties are missing.

@manast manast added the bug label Apr 12, 2019
@Gappa88
Copy link
Author

Gappa88 commented Apr 15, 2019

hi @manast ,
is there a workaround for this issue? do you have time to fix this?

thanks

@manast
Copy link
Member

manast commented Apr 15, 2019

It is a missing feature. It needs to be implemented I am have a lot on my table right now so I cannot do an ETA right now.

@it-fm
Copy link

it-fm commented Aug 17, 2019

Any update ?

@manast manast added the PRIO 1 label Aug 17, 2019
@vin-ni
Copy link

vin-ni commented Apr 13, 2020

+1 :)

@stale
Copy link

stale bot commented Jul 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 12, 2021
github-actions bot pushed a commit that referenced this issue Jul 13, 2021
# [3.23.0](v3.22.12...v3.23.0) (2021-07-13)

### Features

* support job.update function in sandboxed processors ([ff79fb4](ff79fb4)), closes [#1279](#1279) [#1608](#1608) [#1056](#1056)
@manast
Copy link
Member

manast commented Jul 13, 2021

🎉 This issue has been resolved in version 3.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants