neondatabase / neondatabase/serverless

tlsReadLoop() is not awaited and has no .catch() — TLS read errors silently hang the pg client forever

Open Beginner friendly
#217 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
548
Forks
81
PR merge metrics
No merged PRs in 30d

Description

Bug description

src/shims/net/index.ts line 645 starts tlsReadLoop() with a comment saying it's "deliberately NOT awaited", but provides no error handling:

// deliberately NOT awaited; runs in background
tlsReadLoop(); // ← no .catch()

If the TLS read loop rejects (e.g. mid-stream connection drop, unexpected EOF), the error becomes an unhandled promise rejection. The socket never emits 'error' or 'close', so the pg client hangs indefinitely — queries never time out, and the connection is never recycled by a pool.

tlsWrite() (same file, nearby) was fixed to handle errors. tlsReadLoop() has the same gap.

Fix
tlsReadLoop().catch((err) => {
  this.emit('error', err);
  this.emit('close');
});
Environment
  • Verified against current main branch

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/shims/net/index.ts around line 645 and compare the unawaited tlsReadLoop() with the nearby tlsWrite() error handling. Verify that a rejected TLS read emits both error and close so a dropped connection does not hang the pg client or its pool.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.