Skip to content

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

Open
@colleeseum

Description

@colleeseum

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions