Query errors get a read-only `stack` on Node 22+
Maintainers usually reply within 7 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, nodejs, postgresql
Research direction
Start in src/connection.js at queryError, where Object.defineProperties replaces the error's stack. Reproduce the issue with Node 22+ using the provided strict-mode example, then verify the query-error path preserves writable and configurable stack attributes. Done means assigning a new stack no longer throws for errors produced by a query.
Written by the indexing model from the issue text.
Description
queryError in src/connection.js (3.4.9; the same code is on master) appends the query origin like this:
Object.defineProperties(err, {
stack: { value: err.stack + query.origin.replace(/.*\n/, '\n'), enumerable: options.debug },
// ...
})
Since Node 22, stack on an Error instance is an own accessor property. Redefining it with only value turns it into a data property, and writable defaults to false. As a result every query error ends up with a read-only stack. Strict-mode code that rewrites the stack then throws, and error-normalizing frameworks do rewrite it.
Repro (Node 22.23, 24.0, 24.21)
'use strict'
const e = new Error('x')
Object.defineProperties(e, { stack: { value: e.stack } })
e.stack = 'y' // TypeError: Cannot assign to read only property 'stack' of object 'Error: x'
With postgres.js:
'use strict'
const err = await sql`select 1/0`.catch(e => e)
err.stack = 'y' // same TypeError
Suggested fix
stack: { value: /* ... */, enumerable: options.debug, writable: true, configurable: true },
This restores the attributes the property had before Node 22.
Impact
The Vercel Workflow step executor rewrites a thrown error's stack before it records a retry. That assignment threw inside its catch block, so a transient database error left the step running until its lease expired, instead of retrying it.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 389
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from porsager/postgres
-
Cancelled query leaves stale row index; next query on the connection returns leading empty slotsPossibly taken @pislm claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 7 days
-
Reconnect after a close with a pending write never sends StartupMessage: stale nextWriteTimer/chunk make every statement fail CONNECT_TIMEOUTPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 7 days
-
Connection reconnect rejects the next query with a stale ErrorResponse from before the socket closedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 7 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 7 days
-
nextWrite() throws an uncaughtException when a reserved connection's backend diesPossibly taken @XavierGeerinck claimed this 44 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
porsager/postgres#1208 · 8 comments ·
Maintainers usually reply within 7 days
All issues in porsager/postgres
Similar issues
-
change request evaluating
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sindresorhus/eslint-plugin-unicorn#3907 ·
Maintainers usually reply within 1 day
-
Android bug feature/error-tracking react-native team/error-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PostHog/posthog-js#5310 · 1 comment ·
Maintainers usually reply within 1 day
-
Add Prettier and a format-check CI jobPossibly taken @ezekielnathaniel070-ai claimed this today. Openbackend frontend good first issue Stellar Wave
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OlaGreat/starbound-realms#98 · 1 comment ·
-
Add AudiobookshelfOpenapp request good first issue help wanted self-hosted app
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Secra-Solutions/Conector#15 ·
-
Complexity: See issue making label epic good first issue Issue Making: Level 1 P-Feature: Project Info and Page role: back end/devOps role: front end size: 0.25pt time sensitive
Difficulty 2/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day