KurtzL / nestjs-temporal

Temporal plugin for nestjs framework
MIT License
102 stars 21 forks source link

Squash worker shutdown errors #38

Closed clintonb closed 1 year ago

clintonb commented 1 year ago

I am migrating a service to use NestJS. The workers share a connection and client. Shutting down the service results in the error below. The client is most likely being shutdown before the worker. Admittedly, this is a problem of my own making; but, it would be ideal if this error were squashed and logged, rather than bubbling up.

[17:00:59.990] ERROR (49994): Error happened during shutdown
    context: "NestApplicationContext"
    err: {
      "type": "Error",
      "message": "Error happened during shutdown",
      "stack":
          IllegalStateError: Not running
              at Worker.shutdown (/Users/clintonb/vori/backend/node_modules/@temporalio/worker/src/worker.ts:755:13)
              at TemporalExplorer.onModuleDestroy (/Users/clintonb/vori/backend/node_modules/nestjs-temporal/dist/temporal.explorer.js:49:68)
              at MapIterator.iteratee (/Users/clintonb/vori/backend/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:22:43)
              at MapIterator.next (/Users/clintonb/vori/backend/node_modules/iterare/src/map.ts:9:39)
              at IteratorWithOperators.next (/Users/clintonb/vori/backend/node_modules/iterare/src/iterate.ts:19:28)
              at Function.from (<anonymous>)
              at IteratorWithOperators.toArray (/Users/clintonb/vori/backend/node_modules/iterare/src/iterate.ts:227:22)
              at callOperator (/Users/clintonb/vori/backend/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:23:10)
              at callModuleDestroyHook (/Users/clintonb/vori/backend/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:43:23)
              at NestApplication.callDestroyHook (/Users/clintonb/vori/backend/node_modules/@nestjs/core/nest-application-context.js:234:53)
              at processTicksAndRejections (node:internal/process/task_queues:96:5)
              at async process.cleanup (/Users/clintonb/vori/backend/node_modules/@nestjs/core/nest-application-context.js:188:17)
    }

https://github.com/KurtzL/nestjs-temporal/blob/4b0b0c58ced8af90c7ee42c1772e6468f808f6ec/lib/temporal.explorer.ts#L53