Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create connection return Pending even with Await on MacOS with PG #9

Open
colleeseum opened this issue May 31, 2020 · 2 comments
Open

Comments

@colleeseum
Copy link

MacOS Catalina 10.15.4

How to reproduce, simply install using quick guide

npm install typeorm --save
npm install reflect-metadata --save
npm install @types/node --save
npm install pg --save
npm install typeorm -g
typeorm init --name MyProject --database postgres
cd MyProject
npm install
npm start

It will simply return

➜  MyProject npm start

> MyProject@0.0.1 start /Users/sergecolle/work/eve/MyProject
> ts-node src/index.ts

When troubleshooting I found that neither the code in then and catch got executed. After modifying the code, to something like

const connection:Connection = await createConnection()

the connection will be in state Pending and then the program simply skip then and catch and terminate.

I have ask a friend to try it on his mac and he get the same issue.

there the package.json generated by the typeorm install

   "name": "MyProject",
   "version": "0.0.1",
   "description": "Awesome project developed with TypeORM.",
   "devDependencies": {
      "ts-node": "3.3.0",
      "@types/node": "^8.0.29",
      "typescript": "3.3.3333"
   },
   "dependencies": {
      "typeorm": "0.2.25",
      "reflect-metadata": "^0.1.10",
      "pg": "^7.3.0",
      "express": "^4.15.4",
      "body-parser": "^1.18.1"
   },
   "scripts": {
      "start": "ts-node src/index.ts"
   }

and the ormconfig.json

{
   "type": "postgres",
   "host": "localhost",
   "port": 5432,
   "username": "test",
   "password": "test",
   "database": "test",
   "synchronize": true,
   "logging": false,
   "entities": [
      "src/entity/**/*.ts"
   ],
   "migrations": [
      "src/migration/**/*.ts"
   ],
   "subscribers": [
      "src/subscriber/**/*.ts"
   ],
   "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
   }
}

and made sure a postgres db with those credential existed using the psql command.

The tsconfig.json generated

{
   "compilerOptions": {
      "lib": [
         "es5",
         "es6"
      ],
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "outDir": "./build",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "sourceMap": true
   }
}

The lib and target seem a little old to support async/await. I tried updating it to es2017, es2018, and esnext but no luck

@colleeseum
Copy link
Author

A little more info. The same steps work perfectly on Linux. So we can reproduce on MacOS, but work well on Linux.

@adelin-vegannection
Copy link

I have the same issue. I had a project working fine on Ubuntu and then set it up on my MacBook, where createConnection().then() never actually runs. Nor does catch().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants