MCPcopy Create free account
hub / github.com/Effect-TS/effect / begin

Function begin

packages/sql/pg/src/PgConnection.ts:2397–2418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2395 socket.write(frame)
2396 }
2397 const begin = (): void => {
2398 if (config.ssl === false) return send()
2399 socket.once("data", (chunk: Uint8Array) => {
2400 if (done) return
2401 // A TLS session's cancel secret must stay encrypted.
2402 if (chunk.length === 1 && chunk[0] === 0x4e && config.sslOptional && !session.encrypted) return send()
2403 if (chunk.length !== 1 || chunk[0] !== 0x53) return finish()
2404 const raw = socket
2405 raw.off("error", finish)
2406 raw.off("close", finish)
2407 socket = Tls.connect({
2408 host: config.host,
2409 servername: Net.isIP(config.host) === 0 ? config.host : undefined,
2410 ...(typeof config.ssl === "object" ? config.ssl : {}),
2411 socket: raw as Net.Socket
2412 })
2413 socket.on("error", finish)
2414 socket.on("close", finish)
2415 socket.once("secureConnect", send)
2416 })
2417 socket.write(PgProtocol.encodeSslRequest())
2418 }
2419 try {
2420 socket = config.stream !== undefined
2421 ? config.stream()

Callers 2

sendCancelRequestFunction · 0.70
connectFunction · 0.70

Calls 7

startupFunction · 0.85
onceMethod · 0.80
sendFunction · 0.70
finishFunction · 0.70
connectMethod · 0.65
onMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected