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

TypeError: this.stream.write is not a function error when PGSSLMODE is set to use SSL #3294

Open
alinaliBQ opened this issue Aug 14, 2024 · 4 comments

Comments

@alinaliBQ
Copy link

alinaliBQ commented Aug 14, 2024

When I set PGSSLMODE to require or prefer, I get TypeError: this.stream.write is not a function error when I try to run the tests under packages/pg. What could be the cause of this error? This error message is very cryptic. Have others seen this before?

Error log: (replaced full project path with simplified path)

throw-in-type-parser-tests.js
  emits error FAILED!

TypeError: this.stream.write is not a function
    at Connection.requestSsl (JavascriptDriverTest/packages/pg/lib/connection.js:122:17)
    at Connection.<anonymous> (JavascriptDriverTest/packages/pg/lib/client.js:119:13)
    at Connection.emit (node:events:517:28)
    at Object.makeClient [as client] (JavascriptDriverTest/packages/pg/test/unit/client/test-helper.js:15:21)
    at Test.action (JavascriptDriverTest/packages/pg/test/unit/client/throw-in-type-parser-tests.js:39:23)
    at Test._run (JavascriptDriverTest/packages/pg/test/suite.js:32:19)
    at Test.run (JavascriptDriverTest/packages/pg/test/suite.js:14:12)
    at Suite.run (JavascriptDriverTest/packages/pg/test/suite.js:57:10)
    at JavascriptDriverTest/node_modules/async/dist/async.js:4099:9
    at Object.process (JavascriptDriverTest/node_modules/async/dist/async.js:2347:17)

xargs: node: exited with status 255; aborting
make: *** [test-unit] Error 124
npm ERR! Lifecycle script `test` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: [email protected] 
npm ERR!   at location: JavascriptDriverTest/packages/pg 

Commands to reproduce this error:

cd packages/pg
PGUSER=test \
PGPASSWORD=test \
PGHOST=localhost \
PGDATABASE=postgres \
PGPORT=5432 \
PGSSLMODE=require \
npm test

System: CentOS

@alinaliBQ alinaliBQ changed the title TypeError: this.stream.write is not a function when PGSSLMODE is set to use SSL TypeError: this.stream.write is not a function error when PGSSLMODE is set to use SSL Aug 14, 2024
@alinaliBQ
Copy link
Author

alinaliBQ commented Aug 28, 2024

I found more information, the error is caused by stream being undefined at this.stream.write(serialize.requestSsl())

@charmander
Copy link
Collaborator

The tests aren’t currently written to be runnable with PG* environment variables. You might have better luck with make test-all connectionString=postgres://localhost:5432/?sslmode=require.

@alinaliBQ
Copy link
Author

alinaliBQ commented Sep 4, 2024

Ohh I see, thanks for letting me know @charmander

@alinaliBQ
Copy link
Author

I realize this error seems to only be present with unit tests

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