Closed pencilcheck closed 2 years ago
First, you should not be including a require
call inside nested code. Require calls should be top-level imports or requires.
This code const { Client } = require("pg").native;
should be moved to the top of the file.
Secondly, you did not read the pg
documentation at https://node-postgres.com/features/connecting.
You need to include inside your code await client.connect()
.
Please read the documentation for the package you are using before filing an issue in a completely different dependency.
This code would not even work if you included it as a simple app and ran it with node app.js
(without any of the work thread stuff).
Ah, the real reason is because of the pg version I used is not compatible with the node version 14 https://node-postgres.com/#version-compatibility
Describe the bug
Node.js version: v14.18.3
OS version: Mac OSX 12.0.1
Description: Worker can't query database connection, it seems to get stuck and never move to the next line.
I uses "pg" package from node, and connects to the database and try to run .query like some basic select statement.
Somehow the code always get stuck at the query statement.
A separate side note: If I use pooling from "pg" to connect, the CPU of the node running bree worker will goes up to 100%, not sure why.
Actual behavior
Expected behavior
Code to reproduce
https://gist.github.com/pencilcheck/758e36120f6a106328698379682c828a
Checklist