KurtzL / nestjs-temporal

Temporal plugin for nestjs framework
MIT License
107 stars 22 forks source link

Worker NPE #5

Closed rbialek closed 1 year ago

rbialek commented 2 years ago

I'm trying to test your plugin but of some reason I keep getting this error. Any ideas?

Thanks RB

Debugger listening on ws://127.0.0.1:36729/7085afc2-535f-430f-94e8-d9f561398b9c For help, see: https://nodejs.org/en/docs/inspector Debugger attached. [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [NestFactory] Starting Nest application... [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [InstanceLoader] AppModule dependencies initialized +60ms [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [InstanceLoader] TemporalModule dependencies initialized +0ms [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [InstanceLoader] TemporalModule dependencies initialized +0ms [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [InstanceLoader] DiscoveryModule dependencies initialized +1ms [Nest] 3141873 - 05/24/2022, 2:08:38 PM LOG [InstanceLoader] TemporalModule dependencies initialized +0ms /home/rbialek/nest-temporal/node_modules/nestjs-temporal/dist/temporal.explorer.js:55 yield worker_1.Core.install(coreConfig); ^ TypeError: Cannot read properties of undefined (reading 'install') at TemporalExplorer. (/home/rbialek/nest-temporal/node_modules/nestjs-temporal/dist/temporal.explorer.js:55:37) at Generator.next () at fulfilled (/home/rbialek/nest-temporal/node_modules/nestjs-temporal/dist/temporal.explorer.js:14:58) Waiting for the debugger to disconnect...

KurtzL commented 2 years ago

Hello @rbialek , could please tell us which version of the dependence you are using. Also send a snippet of TemporalModule configuration

efrengarcial commented 2 years ago

hello @KurtzL good day, I am having the same problem, I include the information you are requesting:

"dependencies": {
    "@nestjs/common": "^9.0.3",
    "@nestjs/config": "^2.2.0",
    "@nestjs/core": "^9.0.0",
    "@nestjs/mapped-types": "^1.1.0",
    "@nestjs/platform-express": "^9.0.0",
    "@nestjs/typeorm": "^9.0.0",
    "@temporalio/activity": "^1.0.0-rc.1",
    "@temporalio/client": "^1.0.0-rc.1",
    "@temporalio/worker": "^1.0.0-rc.1",
    "@temporalio/workflow": "^1.0.0-rc.1",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "dotenv": "^16.0.1",
    "joi": "^17.6.0",
    "nestjs-temporal": "^0.0.5",
    "pg": "^8.7.3",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0",
    "typeorm": "^0.3.7"
  },
@Module({
  imports: [
    PostsModule, 
    DatabaseModule,
    ConfigModule.forRoot({
      load: [config], 
      isGlobal: true,
      cache: true,
    }),
    TemporalModule.forRoot({
      taskQueue: 'default',
      workflowsPath: require.resolve('./temporal/workflow'),
    }),

    TemporalModule.registerClient(),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Thanks a lot

brianlu-scale commented 2 years ago

Hey, ran into this as well. I think the problem is an incompatibility of temporalio's typescript sdk versions, where in the newer versions such as the one that @efrengarcial is using, the @temporalio/worker no longer contains a Core class. You can see the changelog here: https://github.com/temporalio/sdk-typescript/blob/main/CHANGELOG.md#0200---2022-04-06. I'm working on my own fork of this package (https://github.com/brianlu-scale/nestjs-temporal) that tries to support the temporalio/worker version of 1.0.0, but still running into some issues with client connection that I'd appreciate help from @KurtzL on.

macielcr7 commented 2 years ago

@brianlu-scale is there any complete example using this module?

2022-09-22T21:16:21.922Z [INFO] Worker state changed { state: 'RUNNING' } 2022-09-22T21:16:21.923Z [WARN] No activities registered, not polling for activity tasks

brianlu-scale commented 2 years ago

@macielcr7 https://github.com/brianlu-scale/nestjs-temporal is up to date. As for examples of using it, look at the README

macielcr7 commented 2 years ago

@brianlu-scale using the example, in the temporal it informs that there is no worker started.. how should i called in nest?

macielcr7 commented 2 years ago

TemporalExplorer onInvoke await this.runWorker();

/node_modules/memfs/lib/volume.js:295 throw new TypeError(ERRSTR.PATH_STR); TypeError: path must be a string or Buffer

macielcr7 commented 2 years ago

solved this problem, maybe it's not the best way but that's how I solved it.

workflowsPath: path.resolve(__dirname+'/temporal/workflow.js'),

brianlu-scale commented 2 years ago

sorry just saw this, I think they also suggest using a workflowsBundle if you want to do that instead of passing in a workflows path

brianlu-scale commented 2 years ago

this seems like more of a Temporal specific issue rather than a nestjs-temporal package issue

KurtzL commented 2 years ago

Hello @macielcr7, if you have a little trouble understanding the use of nestjs-temporal. I can try to improve the README

macielcr7 commented 2 years ago

@KurtzL it's a good idea to improve the README

jdnichollsc commented 1 year ago

@KurtzL it's a good idea to improve the README

Any pull request is welcome! :+1:

clintonb commented 1 year ago

For future readers who have issues with bundles: see https://docs.temporal.io/application-development/foundations#register-types. You'll need a pre-build script that bundles your TypeScript into JavaScript, and a helper that switches between workflowsPath and workflowBundle (in production).

This may be Temporal-specific (and I don't have a whole lot of experience with Temporal or NestJS), but this seems like an issue that many users may encounter, and definitely work a documentation update.