Repository navigation
Doesn't work under Node.js 6.0.0 #1000
Description
Activity
I get the same error
error fetching client from pool { error: password authentication failed for user "username" at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:539:11) at Connection.parseMessage (/usr/src/app/node_modules/pg/lib/connection.js:366:17) at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:105:22) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:172:18) at Socket.Readable.push (_stream_readable.js:130:10) at TCP.onread (net.js:535:20) name: 'error', length: 93, severity: 'FATAL', code: '28P01', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'auth.c', line: '285', routine: 'auth_failed' }My Test environment:
- Docker Node v6.0.0
Reacted by Code Scratcher, Jonathan Rose Dunlap, Matthieu Vion, Bohdan Moskalevskyi and gyrilI wonder how this happened? There shouldn't be an API breaking change in v6 other than the worker process API.
Btw, what's this file: 'auth.c' file being mentioned?
Btw, what's this file: 'auth.c' file being mentioned?
That's where all the authentication mambo-jumbo happens inside PostgreSQL server code. It is always mentioned on any authentication-related error.
I've done some initial debugging, and I am almost certain the issue is caused by one of the changes to the
Buffer.From the change-log:
The following significant changes have been made since the previous Node.js v5.0.0 release:
- Buffer
- New Buffer constructors have been added
#4682 and
#5833. - Existing
Buffer()andSlowBuffer()constructors have been deprecated
in docs #4682 and
#5833. - Previously deprecated Buffer APIs are removed
#5048,
#4594. - Improved error handling #4514.
- The
Buffer.prototype.lastIndexOf()method has been added
#4846.
- New Buffer constructors have been added
For example, if I do something like this:
Connection.prototype.parseCString = function(buffer) { console.log('BUFFER:', buffer.length); var start = this.offset; while(buffer[this.offset++] !== 0) { } return buffer.toString(this.encoding, start, this.offset - 1); };
in file
connection.js, i see immediate change in the received buffer length as I change to Node.js 6.0.0- Buffer
Same issue here
Reacted by Code Scratcher, Matthieu Vion, Tyler Sheaffer and Ashutosh Singhignitenet-martynas commented
on Apr 27, 2016 ContributorMore actionsHello everyone,
Here's what fixes the Node v6.0.0 problem:
https://github.com/ignitenet-martynas/node-postgres/commit/77560fe1bbc80ba0a629720161d81dbb6286166d
Reacted by Awal Garg, Denys Séguret, Florian Margaine, Eugene Sokolov, Cymen Vig, Nick Müller, Jonathan Rose Dunlap, Code Scratcher, Bohdan Moskalevskyi, Nick Floersch (he/him) and 3 moreReacted by casey-prominenttechnologyReacted by Jonathan Rose Dunlap, Code Scratcher and Nick Floersch (he/him)I confirm it works for me
Works for me too.
I confirm this to be the fix indeed! Thank you @ignitenet-martynas !
So it was the
Bufferas I thought :)@brianc Now we just need the PR to make into a new release ;) And I think it should be 4.6.0 ;)
Reacted by Max Metral, Bohdan Moskalevskyi and unleash-orgThe issue has been resolved with 4.5.5 release.
Thank you @ignitenet-martynas and @brianc 👍
Reacted by unleash-org and Arnaud BenhamdineReacted by Max Metral, Code Scratcher, Jonathan Rose Dunlap, Matt Mueller, rfink and VirtualWolfThanks for your help with reporting it & digging in and finding it was an issue with the buffer @vitaly-t!!
Reacted by Code Scratcher, Max Metral, Ryan Havar, Jonathan Rose Dunlap and Arnaud Benhamdine- added a commit that references this issue
on Apr 27, 2016 - added a commit that references this issue
on Apr 28, 2016 8 remaining items
DOESnt work for me.
have same problem,,and i try your solution but still error, cannot 'gulp serve'
hope your help.PS C:\webproj\dreamhouse-web-app> gulp serve
[10:45:36] Using gulpfile C:\webproj\dreamhouse-web-app\gulpfile.js
[10:45:36] Starting 'clean'...
[10:45:36] Finished 'clean' after 69 ms
[10:45:36] Starting 'watch'...
[10:45:36] Starting 'sass'...
[10:45:36] Starting 'html'...
[10:45:36] Starting 'fonts'...
[10:45:36] Starting 'scripts'...
[10:45:36] Finished 'scripts' after 118 ms
[10:45:36] Finished 'html' after 160 ms
[10:45:36] Finished 'fonts' after 177 ms
[10:45:38] Finished 'sass' after 2.14 s
7.6 MB bytes written (9.89 seconds)
[10:45:49] Finished 'watch' after 13 s
[10:45:49] Starting 'serve'...
Listening at: http://localhost:8200
[10:45:49] Finished 'serve' after 302 ms
events.js:160
throw er; // Unhandled 'error' event
^error: password authentication failed for user "taufikmas"
at Connection.parseE (C:\webproj\dreamhouse-web-app\node_modules\pg\lib\connection.js:539:11)
at Connection.parseMessage (C:\webproj\dreamhouse-web-app\node_modules\pg\lib\connection.js:366:17)
at Socket. (C:\webproj\dreamhouse-web-app\node_modules\pg\lib\connection.js:105:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)@fixduino did you test it under Node 4.x? Which version of
node-postgresare you using?i use latest node 6.0 . win10.
is node jss 6.0 not support pg 4.5.5?
i try for this tutorial https://github.com/dreamhouseapp/dreamhouse-web-app@fixduino try Node.js 4.x, your problem could be unrelated, i.e. if you still get the same error, then it is not related, and you simply got your password wrong.
Reacted by taufikmas@fixduino I'd need to see your code but it looks like you're using the wrong password.
Reacted by taufikmasi never put my password. where is location for set password? thx
client.js -- https://pastebin.com/XQYs5xWv
conection-parameters.js -- https://pastebin.com/44mHmsgh
thx for helpSOLVED.. just a little mistake to set parameter..
in server.js
var connectionString = process.env.DATABASE_URL || 'postgres://postgres:admin@localhost:5432/dreamhouse'; //postgres://YourUserName:YourPassword@localhost:5432/YourDatabase";
thanks all.win10. nodejs 6.0
Excuse me I cannot open this link https://github.com/ignitenet-martynas/node-postgres/commit/77560fe1bbc80ba0a629720161d81dbb6286166d it show 404 not found
@endermaxximum Well the fix has been integrated into node-postgres quite a while ago therefore I deleted the fork...
okay.thank you
could you help me what wrong with my code? @ignitenet-martynas
here is my code: `var express = require('express'),
path = require('path'),
bodyParser = require('body-parser'),
cons = require('consolidate'),
dust = require('dustjs-helpers'),
pg = require('pg'),
app = express();
var pool = new pg.Pool()
// DB Connect String
// from owner Loaserver pass 00000000
var connect ="postgres://Loraserver:00000000@localhost/Lopicaserver";// Assign Dust Engine to .dust Files
app.engine('dust', cons.dust);// Set Default Ext .dust
app.set('view engine', 'dust');
app.set('views', __dirname + '/views');// Set Public Folder
app.use(express.static(path.join(__dirname, 'public')));// Body Parser Middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));app.get('/', function(req, res){
//connect using created pool
pool.connect(function(err, client, done) {
if(err) {
return console.error('error fetching client from pool', err);
}
client.query('SELECT * FROM public.loradata', function(err, result){
if(err){
return console.error('error running query', err);
}
res.render('index', {loradata: result.rows});
done();
});
});
});// Server
app.listen(3000, function(){
console.log('Server Started On Port 3000');
});`@endermaxximum Your connection string isn’t used anywhere. Pass it to the pool constructor (documentation):
var pool = new pg.Pool({ connectionString: "postgres://Loraserver:00000000@localhost/Lopicaserver", });
Thank you so much.
@charmander

If we take the example on the main page:
And simply switch to Node.js 6.0.0, we are immediately getting an error:
i.e. authentication doesn't work under the newly released Node.js 6.0.0
My Test environment: