Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Merge requests
  • !160

Try to be smart about the handler

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/curit/try-to-be-smart-about-handler into master Aug 27, 2015
  • Overview 5
  • Commits 3
  • Pipelines 0
  • Changes 2

Created by: albertjan

This tries to resolve the easy to make mistake with specifying a handler with a callback and returning a promise.

It's a bit intricate but it does the job 😄.

This will make these work:

queue.process(function(job, done) {
  return Promise.resolve();
});

and

queue.process(function(job, done) {
  return 5;
});

This one will probably create a race condition (for as far as possible in js):

queue.process(function(job, done) {
   done(5);
   return Promise.resolve(6);
});

And this one will outright not work for obvious reasons:

queue.process(function(job, done) {
  setTimeout(done, 500);
  return 4;
});
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/curit/try-to-be-smart-about-handler