Not able to use Seperate Processes with bull
Hey Coders,
I have been using Bull for a while with separate processes for doing data processing and uploads but recently our production started failing all these requests because somehow bull is not able to find the process which actually exists in the project.
After digging into the code for a while I understood that under the hood it's using require
to load the process/module. So, I tried loading the code myself with the exact same file path (for your information it's an absolute path). It loaded here perfectly but with Bull, it's failing to load the module and throwing an error.
{ stack: 'Error: Error loading process file /home/vaibhav/Documents/Projects/Ant Mascot/apis/src/workers/category-upload.ts. Cannot set an undefined handler\n' + ' at Queue.setHandler (/home/vaibhav/Documents/Projects/Ant Mascot/apis/node_modules/bull/lib/queue.js:670:11)\n' + ' at Queue.process (/home/vaibhav/Documents/Projects/Ant Mascot/apis/node_modules/bull/lib/queue.js:654:8)\n' + ' at Object.<anonymous> (/home/vaibhav/Documents/Projects/Ant Mascot/apis/src/lib/bull/use-cases/uploadCategories.ts:24:20)\n' + ' at Module._compile (node:internal/modules/cjs/loader:1120:14)\n' + ' at Module.m._compile (/home/vaibhav/Documents/Projects/Ant Mascot/apis/node_modules/ts-node/src/index.ts:1618:23)\n' + ' at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)\n' + ' at Object.require.extensions.<computed> [as .ts] (/home/vaibhav/Documents/Projects/Ant Mascot/apis/node_modules/ts-node/src/index.ts:1621:12)\n' + ' at Module.load (node:internal/modules/cjs/loader:998:32)\n' + ' at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n' + ' at Module.require (node:internal/modules/cjs/loader:1022:19)\n' + ' at require (node:internal/modules/cjs/helpers:102:18)\n' + ' at Object.<anonymous> (/home/vaibhav/Documents/Projects/Ant Mascot/apis/src/lib/bull/index.ts:13:1)\n' + ' at Module._compile (node:internal/modules/cjs/loader:1120:14)\n' + ' at Module.m._compile (/home/vaibhav/Documents/Projects/Ant Mascot/apis/node_modules/ts-node/src/index.ts:1618:23)\n' + ' at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)\n' + ' at Object.require.extensions.<computed> [as .ts] (/home/vaibhav/Documents/Projects/...../apis/node_modules/ts-node/src/index.ts:1621:12)', message: 'Error loading process file ..../workers/category-upload.ts. Cannot set an undefined handler' }
I am using the latest version of bull (4.10.4) with typescript. Just for verifying the issue, I build the project and run, still same problem.