Comparing version 8.12.0 to 8.13.0
@@ -102,3 +102,2 @@ 'use strict' | ||
this.connectionTimeoutHandle | ||
if (this._connectionTimeoutMillis > 0) { | ||
@@ -382,2 +381,7 @@ this.connectionTimeoutHandle = setTimeout(() => { | ||
_handleCommandComplete(msg) { | ||
if (this.activeQuery == null) { | ||
const error = new Error('Received unexpected commandComplete message from backend.') | ||
this._handleErrorEvent(error) | ||
return | ||
} | ||
// delegate commandComplete to active query | ||
@@ -387,3 +391,8 @@ this.activeQuery.handleCommandComplete(msg, this.connection) | ||
_handleParseComplete(msg) { | ||
_handleParseComplete() { | ||
if (this.activeQuery == null) { | ||
const error = new Error('Received unexpected parseComplete message from backend.') | ||
this._handleErrorEvent(error) | ||
return | ||
} | ||
// if a prepared statement has a name and properly parses | ||
@@ -521,3 +530,3 @@ // we track that its already been executed so we don't parse | ||
} else { | ||
readTimeout = this.connectionParameters.query_timeout | ||
readTimeout = config.query_timeout || this.connectionParameters.query_timeout | ||
query = new Query(config, values, callback) | ||
@@ -524,0 +533,0 @@ if (!query.callback) { |
'use strict' | ||
var net = require('net') | ||
var EventEmitter = require('events').EventEmitter | ||
@@ -5,0 +4,0 @@ |
@@ -170,3 +170,3 @@ 'use strict' | ||
} else { | ||
readTimeout = this.connectionParameters.query_timeout | ||
readTimeout = config.query_timeout || this.connectionParameters.query_timeout | ||
query = new NativeQuery(config, values, callback) | ||
@@ -173,0 +173,0 @@ if (!query.callback) { |
@@ -0,28 +1,81 @@ | ||
const { getStream, getSecureStream } = getStreamFuncs() | ||
module.exports = { | ||
/** | ||
* Get a socket stream compatible with the current runtime environment. | ||
* @returns {Duplex} | ||
*/ | ||
getStream, | ||
/** | ||
* Get a TLS secured socket, compatible with the current environment, | ||
* using the socket and other settings given in `options`. | ||
* @returns {Duplex} | ||
*/ | ||
getSecureStream, | ||
} | ||
/** | ||
* Get a socket stream compatible with the current runtime environment. | ||
* @returns {Duplex} | ||
* The stream functions that work in Node.js | ||
*/ | ||
module.exports.getStream = function getStream(ssl) { | ||
const net = require('net') | ||
if (typeof net.Socket === 'function') { | ||
function getNodejsStreamFuncs() { | ||
function getStream(ssl) { | ||
const net = require('net') | ||
return new net.Socket() | ||
} else { | ||
const { CloudflareSocket } = require('pg-cloudflare') | ||
return new CloudflareSocket(ssl) | ||
} | ||
function getSecureStream(options) { | ||
var tls = require('tls') | ||
return tls.connect(options) | ||
} | ||
return { | ||
getStream, | ||
getSecureStream, | ||
} | ||
} | ||
/** | ||
* Get a TLS secured socket, compatible with the current environment, | ||
* using the socket and other settings given in `options`. | ||
* @returns {Duplex} | ||
* The stream functions that work in Cloudflare Workers | ||
*/ | ||
module.exports.getSecureStream = function getSecureStream(options) { | ||
var tls = require('tls') | ||
if (tls.connect) { | ||
return tls.connect(options) | ||
} else { | ||
function getCloudflareStreamFuncs() { | ||
function getStream(ssl) { | ||
const { CloudflareSocket } = require('pg-cloudflare') | ||
return new CloudflareSocket(ssl) | ||
} | ||
function getSecureStream(options) { | ||
options.socket.startTls(options) | ||
return options.socket | ||
} | ||
return { | ||
getStream, | ||
getSecureStream, | ||
} | ||
} | ||
/** | ||
* Are we running in a Cloudflare Worker? | ||
* | ||
* @returns true if the code is currently running inside a Cloudflare Worker. | ||
*/ | ||
function isCloudflareRuntime() { | ||
// Since 2022-03-21 the `global_navigator` compatibility flag is on for Cloudflare Workers | ||
// which means that `navigator.userAgent` will be defined. | ||
if (typeof navigator === 'object' && navigator !== null && typeof navigator.userAgent === 'string') { | ||
return navigator.userAgent === 'Cloudflare-Workers' | ||
} | ||
// In case `navigator` or `navigator.userAgent` is not defined then try a more sneaky approach | ||
if (typeof Response === 'function') { | ||
const resp = new Response(null, { cf: { thing: true } }) | ||
if (typeof resp.cf === 'object' && resp.cf !== null && resp.cf.thing) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
function getStreamFuncs() { | ||
if (isCloudflareRuntime()) { | ||
return getCloudflareStreamFuncs() | ||
} | ||
return getNodejsStreamFuncs() | ||
} |
{ | ||
"name": "pg", | ||
"version": "8.12.0", | ||
"version": "8.13.0", | ||
"description": "PostgreSQL client - pure javascript & libpq with the same API", | ||
@@ -23,5 +23,5 @@ "keywords": [ | ||
"dependencies": { | ||
"pg-connection-string": "^2.6.4", | ||
"pg-pool": "^3.6.2", | ||
"pg-protocol": "^1.6.1", | ||
"pg-connection-string": "^2.7.0", | ||
"pg-pool": "^3.7.0", | ||
"pg-protocol": "^1.7.0", | ||
"pg-types": "^2.1.0", | ||
@@ -33,3 +33,3 @@ "pgpass": "1.x" | ||
"async": "2.6.4", | ||
"bluebird": "3.5.2", | ||
"bluebird": "3.7.2", | ||
"co": "4.6.0", | ||
@@ -63,3 +63,3 @@ "pg-copy-streams": "0.3.0", | ||
}, | ||
"gitHead": "0f42880861951970e193d31359508d460a67d25a" | ||
"gitHead": "92cb640fd316972e323ced6256b2acd89b1b58e0" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79269
2271
4
Updatedpg-connection-string@^2.7.0
Updatedpg-pool@^3.7.0
Updatedpg-protocol@^1.7.0