-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
TypeError: Cannot read properties of undefined (reading 'prepareValue') #3430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Upgrading to latest pg version v8.15.1 might resolve the issue, currently still validating. |
This could happen if you are using something with |
I need steps to reproduce your issue in its entirety. A stack-trace can sometimes be enough but in this case...how do you produce that stack trace? |
It wasn’t intended to be a breaking change; it’s just a bug, and fixing bugs in patch versions is the right thing to do. You should use a lockfile, by the way. |
This was reproduced when running npm install using pg version: 8.14.1 and the lockfile contained pg-cursor 2.14.1.
If this change was not intended then of course it is a bug, no question. My comment was aiming to let the owner or whoever made the change know that if it is intended then add it as a new version and not just a patch version.
Using version 8.15.1 resolved the issue for me. EDIT: testing again older versions as I still see an issue there. I'll try to create a reproducible snippet {
"name": "pg-test",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "Immanuel",
"license": "ISC",
"description": "",
"dependencies": {
"pg": "8.14.1",
"pg-query-stream": "4.9.5"
},
"engines": {
"node": "22.x.x",
"npm": ">=10.x.x"
}
} index.js
Hope this helps. |
A colleague suggested a quick solution/workaround for cases where a version update is not possible. "overrides": {
"pg-cursor": "2.11.0"
}, |
I think I understand it now. the #2353 PR made changes to the node-postgres/packages/pg-cursor/index.js Lines 2 to 4 in 940479b
it was like this before: node-postgres/packages/pg-cursor/index.js Lines 2 to 3 in 81ec063
and node-postgres/packages/pg-cursor/package.json Lines 30 to 32 in 940479b
That's why all previous versions broke, because from minor EDIT: Ok, I've been thinking for a while, and I’ve decided not to open a PR since it ultimately depends on what @brianc wants to do, there are a few possible ways to fix it. For either of the options below (or even another one), it might also be a good idea to start pinning major and minor versions in peer dependencies across packages, to avoid issues in future releases. First optionApply a workaround at node-postgres/packages/pg-cursor/index.js Lines 2 to 4 in 940479b
Modify it like this so both older and newer versions of const pg = require('pg')
const Result = pg.Result || require('pg/lib/result.js')
const prepare = (pg.utils && pg.utils.prepareValue) || require('pg/lib/utils.js').prepareValue Then deprecate this approach in a future major release. Second optionRevert all ESM-related changes and release a new Third optionAdvise users to apply the override workaround when using packages that depend on older |
ah i see if note: I thought learna would take care of this automatically...apparently not |
I'm not sure that just bumping the peer dependency to The real issue is when someone uses So the breakage happens when Example |
Yah your right, read it wrong pre-coffee this morning. I have an idea for a
fix…stand by for a few hrs and i might have something for you!
…On Thu, Apr 24, 2025 at 11:59 AM Breno A. ***@***.***> wrote:
*brenoepics* left a comment (brianc/node-postgres#3430)
<#3430 (comment)>
ah i see if pg-cursor has a peer dep on ***@***.*** i should bump the peer dep
to ***@***.*** and we should be good to go. I can take care of that! ty
note: I thought learna would take care of this automatically...apparently
not
I'm not sure that bumping the peer dependency to ***@***.*** is the right
fix here. Using ***@***.*** with the latest pg-cursor works fine, and has
been working since ***@***.***
The real issue is when someone uses pg-cursor with an older version of pg
(like 8.14.x or earlier). In that case, pg-cursor ends up downloading the
latest pg@^8, which brings in the ESM changes and breaks things because
older versions use another way for imports.
So the breakage happens when pg-cursor is installed alongside an older
pg, not the other way around.
—
Reply to this email directly, view it on GitHub
<#3430 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMHIPBBUJPIWKNY4VEBZ323EJ7LAVCNFSM6AAAAAB3VV7HU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRYGI4DEOJQGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
waiting for it as well, thanks! ^ 🤞 |
None of these breaking changes were supposed to happen & were related to bugs / unexpected side-effects of declaring exactly which files the various modules were exporting. This resulted in deep-requiring files from modules breaking in various ways. I've both added tests to specifically cover importing deeply required files in commonjs and esm, and made sure all those files are exposed. There should be no breaking changes requiring a major version bump, as @charmander said. It was just...bugs....pretty unexpected bugs but so it goes when the library is as widely deployed and used as this one. @sukrukiymaci here is the fix |
fixed in |
Hi @brianc, thanks for the quick handling and fix! {
"name": "pg-test",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "Immanuel",
"license": "ISC",
"description": "",
"dependencies": {
"pg": "8.15.1",
"pg-query-stream": "4.9.6"
},
"engines": {
"node": "22.x.x",
"npm": ">=10.x.x"
}
}
Throws this error:
Should I open a separate ticket for it? |
Hi,
Latest PR: 940479b broke our runtime completely.
This occurred even though we did not upgrade the version of pg so it was a complete surprise.
Issue is coming from:
node-postgres/packages/pg-cursor/index.js
Line 4 in 940479b
Please look into it as soon as possible.
pg version: 8.14.1
node version: 22.12.0
npm version: 10.9.0
Let me know if you need any other details.
The text was updated successfully, but these errors were encountered: