Skip to content

Commit db7d830

Browse files
fixup! refactor: tighten up cloudflare detection
1 parent c5946f3 commit db7d830

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/pg/lib/stream.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* @returns {Duplex}
44
*/
55
module.exports.getStream = function getStream(ssl) {
6-
try {
7-
const { CloudflareSocket } = require('pg-cloudflare')
8-
return new CloudflareSocket(ssl)
9-
} catch {
6+
if (process?.release?.name === 'node') {
107
const net = require('net')
118
return new net.Socket()
9+
} else {
10+
const { CloudflareSocket } = require('pg-cloudflare')
11+
return new CloudflareSocket(ssl)
1212
}
1313
}
1414

@@ -18,11 +18,11 @@ module.exports.getStream = function getStream(ssl) {
1818
* @returns {Duplex}
1919
*/
2020
module.exports.getSecureStream = function getSecureStream(options) {
21-
try {
22-
options.socket.startTls(options)
23-
return options.socket
24-
} catch {
21+
if (process?.release?.name === 'node') {
2522
var tls = require('tls')
2623
return tls.connect(options)
24+
} else {
25+
options.socket.startTls(options)
26+
return options.socket
2727
}
2828
}

0 commit comments

Comments
 (0)