shiny / adonis-resque

Resque Queue for AdonisJS v6
https://packages.adonisjs.com/packages/resque
MIT License
11 stars 2 forks source link

adonis server is crashing before it even starts #1

Closed sayeed205 closed 2 months ago

sayeed205 commented 2 months ago

[ error ] Cannot read properties of undefined (reading 'map')
          at <anonymous> (D:\GitHub\yujin-json\node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\jobs.ts:23:34)
          at Array.reduce (<anonymous>)
          at importAllJobs (D:\GitHub\yujin-json\node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\jobs.ts:11:17)
          at ResqueStart.run (D:\GitHub\yujin-json\node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\commands\resque_start.ts:50:22)
          at async ResqueStart.exec (file:///D:/GitHub/yujin-json/node_modules/.pnpm/@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0/node_modules/@adonisjs/core/build/modules/ace/commands.js:51:28)
          at Kernel.#exec (D:\GitHub\yujin-json\node_modules\.pnpm\@adonisjs+ace@13.0.0\node_modules\@adonisjs\ace\src\kernel.ts:277:5)
          at ResqueProvider.start (D:\GitHub\yujin-json\node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\providers\resque_provider.ts:37:32)
          at ProvidersManager.start (D:\GitHub\yujin-json\node_modules\.pnpm\@adonisjs+application@8.2.2_@adonisjs+config@5.0.2_@adonisjs+fold@10.1.2\node_modules\@adonisjs\application\src\managers\providers.ts:186:9)
          at Application.start (D:\GitHub\yujin-json\node_modules\.pnpm\@adonisjs+application@8.2.2_@adonisjs+config@5.0.2_@adonisjs+fold@10.1.2\node_modules\@adonisjs\application\src\application.ts:549:5)
          at async HttpServerProcess.start (file:///D:/GitHub/yujin-json/node_modules/.pnpm/@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0/node_modules/@adonisjs/core/build/src/ignitor/http.js:102:9)

   TypeError: Cannot read properties of undefined (reading 'map')

   ⁃ <anonymous>
     node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\jobs.ts:23
   ⁃ importAllJobs
     node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\jobs.ts:11
   ⁃ ResqueStart.run
     node_modules\.pnpm\adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni\node_modules\adonis-resque\commands\resque_start.ts:50
sayeed205 commented 2 months ago

PS D:\GitHub\yujin-json> node ace resque:start
[ error ] Cannot read properties of undefined (reading 'map')
          at file:///D:/GitHub/yujin-json/node_modules/.pnpm/adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni/node_modules/adonis-resque/build/chunk-YXSDERCX.js:21:28
          at Array.reduce (<anonymous>)
          at importAllJobs (file:///D:/GitHub/yujin-json/node_modules/.pnpm/adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni/node_modules/adonis-resque/build/chunk-YXSDERCX.js:9:15)
          at async ResqueStart.run (file:///D:/GitHub/yujin-json/node_modules/.pnpm/adonis-resque@1.2.0_@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qelwcavpxdbd6km2hq56lwjtni/node_modules/adonis-resque/build/commands/resque_start.js:97:18)
          at async ResqueStart.exec (file:///D:/GitHub/yujin-json/node_modules/.pnpm/@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0/node_modules/@adonisjs/core/build/modules/ace/commands.js:51:28)
          at async #execMain (file:///D:/GitHub/yujin-json/node_modules/.pnpm/@adonisjs+ace@13.0.0/node_modules/@adonisjs/ace/build/index.js:1481:7)
          at async AceProcess.handle (file:///D:/GitHub/yujin-json/node_modules/.pnpm/@adonisjs+core@6.9.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0/node_modules/@adonisjs/core/build/src/ignitor/ace.js:66:9)
shiny commented 2 months ago

Thanks for reporting, I'll check later.

shiny commented 2 months ago

Does all your Job classes extends BaseJob from adonis-resque?

shiny commented 2 months ago

importAllJobs assumes that all imported classes are valid, actually, it's not. May be we should check the imported classes, skip the invalid jobs.

shiny commented 2 months ago

you can upgrade to version 1.2.1

sayeed205 commented 2 months ago

Does all your Job classes extends BaseJob from adonis-resque?

yes they do.

I just tried the example job from the readme.

import { BaseJob } from 'adonis-resque'

export default class Spider extends BaseJob {
  async perform(name: string) {
    this.logger.info(`Hello ${name}`)
  }
}
router.get('job', () => {
  SpiderJob.enqueue('Sayed')
})

The problem happens when adonis-resque imported in adonisrc.ts for commands

commands: [
    () => import('@adonisjs/core/commands'),
    () => import('@adonisjs/lucid/commands'),
    () => import('adonis-resque/commands'),
  ],

and when I do node ace make:job <job_name> .

sayeed205 commented 2 months ago

you can upgrade to version 1.2.1

I upgraded to 1.2.1. but some other issue still persist it seems. pnpm dev ->

[ error ] Cannot read properties of undefined (reading 'main')
          at getConnection (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\services\main.ts:9:24)
          at createMultiWorker (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\services\main.ts:32:21)
          at ResqueStart.run (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\commands\resque_start.ts:61:39)
          at async ResqueStart.exec (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0_edge.js@6.0.2/node_modules/@adonisjs/core/build/modules/ace/commands.js:51:28)
          at Kernel.#exec (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\@adonisjs+ace@13.0.0\node_modules\@adonisjs\ace\src\kernel.ts:277:5)
          at ResqueProvider.start (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\providers\resque_provider.ts:37:32)
          at ProvidersManager.start (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\@adonisjs+application@8.2.2_@adonisjs+config@5.0.2_@adonisjs+fold@10.1.2\node_modules\@adonisjs\application\src\managers\providers.ts:186:9)
          at Application.start (D:\GitHub\adonisjs-inertia-test\node_modules\.pnpm\@adonisjs+application@8.2.2_@adonisjs+config@5.0.2_@adonisjs+fold@10.1.2\node_modules\@adonisjs\application\src\application.ts:549:5)
          at async HttpServerProcess.start (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0_edge.js@6.0.2/node_modules/@adonisjs/core/build/src/ignitor/http.js:102:9)

   TypeError: Cannot read properties of undefined (reading 'main')

   ⁃ getConnection
     node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\services\main.ts:9
   ⁃ createMultiWorker
     node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\services\main.ts:32
   ⁃ ResqueStart.run
     node_modules\.pnpm\adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm\node_modules\adonis-resque\commands\resque_start.ts:61

node ace resque:start ->

node ace resque:start
[ error ] Cannot read properties of undefined (reading 'main')
          at getConnection (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm/node_modules/adonis-resque/build/chunk-5SDUSZZN.js:7:33)
          at createMultiWorker (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm/node_modules/adonis-resque/build/chunk-5SDUSZZN.js:28:17)
          at ResqueStart.run (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/adonis-resque@1.2.1_@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+_qum7pqzcf74dxfx3henzsosrfm/node_modules/adonis-resque/build/commands/resque_start.js:104:31)
          at async ResqueStart.exec (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0_edge.js@6.0.2/node_modules/@adonisjs/core/build/modules/ace/commands.js:51:28)
          at async #execMain (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/@adonisjs+ace@13.0.0/node_modules/@adonisjs/ace/build/index.js:1481:7)
          at async AceProcess.handle (file:///D:/GitHub/adonisjs-inertia-test/node_modules/.pnpm/@adonisjs+core@6.8.0_@adonisjs+assembler@7.5.1_typescript@5.4.5__@vinejs+vine@2.0.0_edge.js@6.0.2/node_modules/@adonisjs/core/build/src/ignitor/ace.js:66:9)
sayeed205 commented 2 months ago

Okay it seems it was my fault. I did not set up the @adonis/redis. Please mention that redis need to be setup in order to work.

Please mention about the node ace add @adonisjs/redis to setup the redis.

Okay I tested it and its working fine now.

sayeed205 commented 2 months ago

Closing the issue now

shiny commented 2 months ago

Okay it seems it was my fault. I did not set up the @adonis/redis. Please mention that redis need to be setup in order to work.

Please mention about the node ace add @adonisjs/redis to setup the redis.

Okay I tested it and its working fine now.

I had added the code in configure.ts to clarify the dependency of @adonisjs/redis, but i don't know it did not work as expect.

    await codemods.listPackagesToInstall([{
        name: '@adonisjs/redis',
        isDevDependency: false
    }])

let me have a look into it later.

shiny commented 2 months ago

Oh actually it is already mention in the terminal goes like this

node ace add adonis-resque
[ info ] Installing the package using the following command : pnpm add adonis-resque
❯ Continue ? (y/N) · true
[ wait ] package installed successfully ...
Please install following packages

pnpm add @adonisjs/redis
DONE:    update adonisrc.ts file
[ success ] Installed and configured adonis-resque

I'll improve it to make it more clear.

sayeed205 commented 2 months ago

I'll improve it to make it more clear.

cool