Query errors get a read-only `stack` on Node 22+
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 TypeErrorSuggested 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.
Source: porsager/postgres