holdex / pr-time-tracker

https://autoinvoice-theta.vercel.app
0 stars 3 forks source link

Problem: local development setup guides refinement #315

Closed indralukmana closed 2 weeks ago

indralukmana commented 3 weeks ago

While setting up my local development for achieving #273 the processes are not straight forward and missing quite some details. I also find some issues (which I found the fixes after some digging) that are undocumented. The steps also seems to assumes some services/variables setup already done in the local machine which would make new user/project contributor struggle. Some steps also should be done first before doing others.

It would help to have a more detailed steps also pitfalls that anyone has found/experienced documented. This would help new contributor navigate the project more easily.

The following is my personal notes I intend to refine and write as a proper Solution PR at later time.

notes # pr-time-tracker notes - project requirement `pnpm` `docker` `docker compose` `telebit` - Git clone - Create github access token (classic) - [https://github.com/settings/tokens](https://github.com/settings/tokens) - Copy `.npmrc.example` in root folder to `.npmrc` and change the `NPM_TOKEN` with your generated github access token above - install the project dependency using `pnpm install` — Install telebit ```jsx curl [https://get.telebit.io/](https://get.telebit.io/) | bash ``` ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image.png) - Take note of the forwarding URL in this case it is [`shaggy-termite-71.telebit.io`](http://shaggy-termite-71.telebit.io) YOURS WILL BE DIFFERENT - Run the `pnpm trigger-dev:proxy` - copy the `container/.env.example` to `container/.env` - change the `LOGIN_ORIGIN` and `APP_ORIGIN` to the telebit forwarding URL above - cd to the `container` folder and do `docker compose up` you might get the ```jsx triggerdotdev | [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND host.docker.internal ``` you can try to change the `.env` for the redis url from `"host.docker.internal"` to your host ip address setup triggerdotdev with supabase ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%201.png) when you see this in the `docker compose up` output you can then open your telebit forwarding url on your browser and you will see your local [Trigger.dev](http://Trigger.dev) installation ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%202.png) ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%203.png) login with the `Continue with Email` you will find the magic link on the `docker compose` output copy and open the link on your browser Keep getting this issue when spinning new triggerdotdev and redo the supabase ```jsx triggerdotdev | Applying migration `20240129140944_endpoint_deleted_at_column` triggerdotdev | Applying migration `20240129161848_endpoint_nullable_slug_instead_of_deletedat_column` triggerdotdev | Applying migration `20240130165343_add_composite_index_to_job_run_for_job_id_and_created_at` triggerdotdev | Error: P3018 triggerdotdev | triggerdotdev | A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve triggerdotdev | triggerdotdev | Migration name: 20240130165343_add_composite_index_to_job_run_for_job_id_and_created_at triggerdotdev | triggerdotdev | Database error code: 42P01 triggerdotdev | triggerdotdev | Database error: triggerdotdev | ERROR: relation "public.JobRun" does not exist triggerdotdev | triggerdotdev | DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42P01), message: "relation \"public.JobRun\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("namespace.c"), line: Some(428), routine: Some("RangeVarGetRelidExtended") } triggerdotdev | triggerdotdev | triggerdotdev | /triggerdotdev/packages/database: triggerdotdev |  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @trigger.dev/database@0.0.1 db:migrate:deploy: `prisma migrate deploy` triggerdotdev | Exit status 1 triggerdotdev | + cp packages/database/prisma/schema.prisma apps/webapp/prisma/ triggerdotdev | + cp node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node apps/webapp/prisma/ triggerdotdev | + pnpm --filter webapp db:seed triggerdotdev | triggerdotdev | > webapp@1.0.0 db:seed /triggerdotdev/apps/webapp triggerdotdev | > node prisma/seed.js triggerdotdev | triggerdotdev | 🔌 setting up prisma client to postgresql://postgres.svbbhybsznpucduiqcfy@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?schema=triggerdotdev+&connection_limit=10&pool_timeout=60 triggerdotdev | 🔌 prisma client connected triggerdotdev | 🔌 No database replica, using the regular client triggerdotdev | prisma:info Starting a postgresql pool with 10 connections. triggerdotdev | prisma:error triggerdotdev | Invalid `prisma.integrationDefinition.upsert()` invocation: triggerdotdev | triggerdotdev | triggerdotdev | The table `triggerdotdev` does not exist in the current database. triggerdotdev | PrismaClientKnownRequestError: triggerdotdev | Invalid `prisma.integrationDefinition.upsert()` invocation: triggerdotdev | triggerdotdev | triggerdotdev | The table `triggerdotdev` does not exist in the current database. triggerdotdev | at Cn.handleRequestError (/triggerdotdev/apps/webapp/prisma/seed.js:123:6809) triggerdotdev | at Cn.handleAndLogRequestError (/triggerdotdev/apps/webapp/prisma/seed.js:123:6198) triggerdotdev | at Cn.request (/triggerdotdev/apps/webapp/prisma/seed.js:123:5918) triggerdotdev | at async d (/triggerdotdev/apps/webapp/prisma/seed.js:128:9968) triggerdotdev | at async ty (/triggerdotdev/apps/webapp/prisma/seed.js:632:89819) triggerdotdev | at async ly (/triggerdotdev/apps/webapp/prisma/seed.js:632:91488) { triggerdotdev | code: 'P2021', triggerdotdev | clientVersion: '5.4.1', triggerdotdev | meta: { table: 'triggerdotdev' } triggerdotdev | } triggerdotdev | /triggerdotdev/apps/webapp: triggerdotdev |  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  webapp@1.0.0 db:seed: `node prisma/seed.js` triggerdotdev | Exit status 1 triggerdotdev | + cd /triggerdotdev/apps/webapp triggerdotdev | + NODE_PATH=/triggerdotdev/node_modules/.pnpm/node_modules exec dumb-init node --max-old-space-size=8192 ./build/server.js triggerdotdev | 🔌 setting up prisma client to postgresql://postgres.svbbhybsznpucduiqcfy@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?schema=triggerdotdev+&connection_limit=10&pool_timeout=60 triggerdotdev | 🔌 prisma client connected triggerdotdev | 🔌 No database replica, using the regular client triggerdotdev | 🔦 Tracer: Logger exporter enabled (sampling = 0.05) triggerdotdev | {"pattern":"marqs:*sharedQueue","component":"marqs","operation":"rebalanceParentQueues","service":"marqs","timestamp":"2024-11-08T01:43:59.299Z","name":"webapp","message":"Streaming parent queues based on pattern","level":"debug"} triggerdotdev | {"host":"172.17.0.1","port":6379,"timestamp":"2024-11-08T01:43:59.413Z","name":"webapp","message":"⚡ RedisGraphileRateLimiter connected to Redis","level":"debug"} triggerdotdev | {"keyPrefix":"api","redisKeyspace":"ratelimit:api","timestamp":"2024-11-08T01:44:00.188Z","name":"webapp","message":"RateLimiter (api): initialized","level":"info"} triggerdotdev | {"timestamp":"2024-11-08T01:44:00.198Z","name":"webapp","message":"[migrationHelper] GraphileMigrationHelperService.call","level":"debug"} triggerdotdev | 🥸 Initializing event loop monitor triggerdotdev | ✅ server ready: http://localhost:3030 [NODE_ENV: production] ``` Potential fix is in here [https://github.com/triggerdotdev/trigger.dev/issues/1026](https://github.com/triggerdotdev/trigger.dev/issues/1026) After applying the fix the migrations successfully applied but got this ```jsx triggerdotdev | All migrations have been successfully applied. triggerdotdev | + cp packages/database/prisma/schema.prisma apps/webapp/prisma/ triggerdotdev | + cp node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node apps/webapp/prisma/ triggerdotdev | + pnpm --filter webapp db:seed triggerdotdev | triggerdotdev | > webapp@1.0.0 db:seed /triggerdotdev/apps/webapp triggerdotdev | > node prisma/seed.js triggerdotdev | triggerdotdev | 🔌 setting up prisma client to postgresql://postgres.woaexroydnnwtbcsbiyg@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?schema=triggerdotdev+&connection_limit=10&pool_timeout=60 triggerdotdev | 🔌 prisma client connected triggerdotdev | 🔌 No database replica, using the regular client triggerdotdev | prisma:info Starting a postgresql pool with 10 connections. triggerdotdev | prisma:error triggerdotdev | Invalid `prisma.integrationDefinition.upsert()` invocation: triggerdotdev | triggerdotdev | triggerdotdev | The table `triggerdotdev` does not exist in the current database. triggerdotdev | PrismaClientKnownRequestError: triggerdotdev | Invalid `prisma.integrationDefinition.upsert()` invocation: triggerdotdev | triggerdotdev | triggerdotdev | The table `triggerdotdev` does not exist in the current database. triggerdotdev | at Cn.handleRequestError (/triggerdotdev/apps/webapp/prisma/seed.js:123:6809) triggerdotdev | at Cn.handleAndLogRequestError (/triggerdotdev/apps/webapp/prisma/seed.js:123:6198) triggerdotdev | at Cn.request (/triggerdotdev/apps/webapp/prisma/seed.js:123:5918) triggerdotdev | at async d (/triggerdotdev/apps/webapp/prisma/seed.js:128:9968) triggerdotdev | at async ty (/triggerdotdev/apps/webapp/prisma/seed.js:632:89819) triggerdotdev | at async ly (/triggerdotdev/apps/webapp/prisma/seed.js:632:91488) { triggerdotdev | code: 'P2021', triggerdotdev | clientVersion: '5.4.1', triggerdotdev | meta: { table: 'triggerdotdev' } triggerdotdev | } triggerdotdev | /triggerdotdev/apps/webapp: triggerdotdev |  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  webapp@1.0.0 db:seed: `node prisma/seed.js` ``` Running the `pnpm trigger-dev:proxy` often time got me this ```jsx  pnpm trigger-dev:proxy > pr-time-tracker@0.0.3 trigger-dev:proxy /home/ubuntu/Developer/pr-time-tracker > ~/telebit http 3030 /home/ubuntu/Applications/telebit/bin/telebit-remote.js:643 var verstrd = [ pkg.name + ' daemon v' + state.config.version ]; ^ TypeError: Cannot read property 'version' of undefined at handleConfig (/home/ubuntu/Applications/telebit/bin/telebit-remote.js:643:57) at /home/ubuntu/Applications/telebit/bin/telebit-remote.js:359:22 at /home/ubuntu/Applications/telebit/usr/share/install-launcher.js:241:26 at ChildProcess.exithandler (child_process.js:280:7) at ChildProcess.emit (events.js:182:13) at maybeClose (internal/child_process.js:962:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)  ELIFECYCLE  Command failed with exit code 1.  ``` ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%204.png) ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%205.png) Start the proxy connection via `pnpm run proxy` (this should be done first before others) ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%206.png) ![image.png](pr-time-tracker%201377198f239b80a3875dd463014e3b61/image%207.png)