CollActionteam / collaction_api

The API powering the Collaction Client Applications
GNU Affero General Public License v3.0
7 stars 0 forks source link

[Bug] Scheduler onTick breaks production #136

Closed Xazin closed 1 year ago

Xazin commented 1 year ago

Description: After deploying production, I found out that the application crashes right after startup due to the Nest Scheduler:

Logs ``` > collaction@0.0.1 start:prod > node dist/src/main [04/04/2023, 20:31:09] INFO: Starting Nest application... [04/04/2023, 20:31:10] INFO: AppModule dependencies initialized [04/04/2023, 20:31:10] INFO: ApiModule dependencies initialized [04/04/2023, 20:31:10] INFO: InfrastructureModule dependencies initialized [04/04/2023, 20:31:10] INFO: MongooseModule dependencies initialized [04/04/2023, 20:31:10] INFO: ModulesModule dependencies initialized [04/04/2023, 20:31:10] INFO: CQRSModule dependencies initialized [04/04/2023, 20:31:10] INFO: ConfigHostModule dependencies initialized [04/04/2023, 20:31:10] INFO: DiscoveryModule dependencies initialized [04/04/2023, 20:31:10] INFO: StartupModule dependencies initialized [04/04/2023, 20:31:10] INFO: AuthModule dependencies initialized [04/04/2023, 20:31:10] INFO: ConfigModule dependencies initialized [04/04/2023, 20:31:10] INFO: ConfigModule dependencies initialized [04/04/2023, 20:31:10] INFO: ScheduleModule dependencies initialized [04/04/2023, 20:31:10] INFO: S3Module dependencies initialized [04/04/2023, 20:31:11] INFO: MongooseCoreModule dependencies initialized [04/04/2023, 20:31:11] INFO: MongooseModule dependencies initialized [04/04/2023, 20:31:11] INFO: MongoModule dependencies initialized [04/04/2023, 20:31:11] INFO: ParticipationModule dependencies initialized [04/04/2023, 20:31:11] INFO: CommitmentModule dependencies initialized [04/04/2023, 20:31:11] INFO: ContactModule dependencies initialized [04/04/2023, 20:31:11] INFO: CrowdActionModule dependencies initialized [04/04/2023, 20:31:11] INFO: ProfileModule dependencies initialized [04/04/2023, 20:31:11] INFO: RestModule dependencies initialized [04/04/2023, 20:31:13] INFO: AuthenticationController {/v1/auth}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/auth/sign-in, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/auth/invite-admin, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/auth/verify-email, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/auth/update-password, POST} route [04/04/2023, 20:31:13] INFO: CrowdActionController {/v1/crowdactions}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions/me, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions/:id, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions/slug/:slug, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/crowdactions/:id/images, POST} route [04/04/2023, 20:31:13] INFO: ProfileController {/v1/profiles}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/profiles/me, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/profiles/:userId, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/profiles, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/profiles, PUT} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/profiles/me/image, POST} route [04/04/2023, 20:31:13] INFO: ParticipationController {/v1/participations}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/participations/:crowdActionId, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/participations, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/participations, POST} route [04/04/2023, 20:31:13] INFO: CommitmentController {/v1/commitments}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/commitments, POST} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/commitments/:id, DELETE} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/commitments/:id, PATCH} route [04/04/2023, 20:31:13] INFO: ContactController {/v1/contact}: [04/04/2023, 20:31:13] INFO: Mapped {/v1/contact, GET} route [04/04/2023, 20:31:13] INFO: Mapped {/v1/contact, POST} route [04/04/2023, 20:31:13] INFO: Nest application successfully started [04/04/2023, 20:31:13] INFO: ===================================== [04/04/2023, 20:31:13] INFO: Host: https://api.collaction.org [04/04/2023, 20:31:13] INFO: Port: 3000 [04/04/2023, 20:31:13] INFO: Rest API: https://api.collaction.org/ [04/04/2023, 20:31:13] INFO: ===================================== [04/04/2023, 20:31:13] INFO: [SchedulerService] CreateCron:Successfully - Executed on 635febe269d222318f70af04 [04/04/2023, 20:31:13] ERROR: [SchedulerService] CreateCron:Error - Cron Creation failed for 635febe269d222318f70af04 [04/04/2023, 20:31:13] INFO: [SchedulerService] CreateCron:Successfully - Executed on 63bc606b1a72904c00d8f52c [04/04/2023, 20:31:13] ERROR: [SchedulerService] CreateCron:Error - Cron Creation failed for 63bc606b1a72904c00d8f52c /home/node/app/node_modules/cron/lib/job.js:48 onTick = cronTime.onTick; ^ TypeError: Cannot read properties of undefined (reading 'onTick') at new CJ (/home/node/app/node_modules/cron/lib/job.js:48:22) at SchedulerService.createCron (/home/node/app/dist/src/modules/scheduler/scheduler.service.js:58:32) at SchedulerService.init (/home/node/app/dist/src/modules/scheduler/scheduler.service.js:38:22) at processTicksAndRejections (node:internal/process/task_queues:96:5) ```

This seems to work on Development, which uses npm run start:dev over npm run start:prod.

Xazin commented 1 year ago

For some reason, no matter what I did, even if I used the same way to build as on our Development EC2 Instance, it kept failing on the Production EC2 Instance.

Instead of battling my wits with ECS, I continued work on migrating to Azure. Once done it should solve it.

Xazin commented 1 year ago

Scheduler has been replaced in favor of JIT resolving the status' of the crowdaction.