neondatabase / neondatabase/serverless
tlsReadLoop() is not awaited and has no .catch() — TLS read errors silently hang the pg client forever
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
mainbranch
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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