You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DeprecationWarning: Buffer() is deprecated due to security and usability issues #2426
This issue is happening because of using old version of pg-types module.
Do you have a plan to update pgtypes to 3.x from 2.x?
The latest version of pg-types is using new version of postgres-bytea and this issue has been fixed there.
Oh yes I need to upgrade. I know there are some backwards incompatible changes which is why I've waited so long. I think I should schedule a [email protected] upgrade for some time in January and make it a bundle of breaking changes. @charmander got any other breaking changes that come to mind? I'd like to deprecate the "query queue" concept in 9.0 - add a deprecation warning if you queue a query while another one is still in flight. Thoughts?
@brianc All of that sounds good! BigInt becoming the default value type for BIGINT is also something pg-types might be about to get. If you’re looking to bundle more breaking changes (I guess it’s good for getting people to look at the changelog!), thoughts on these?
No type-parsing defaults, meaning an unknown OID is an error instead of a string (or a binary buffer)?
Splitting the overloaded types query option (it’s an array of OIDs, but also a TypeParser) into incoming and outgoing types
We can open issues to discuss them if they sound worth talking about!
Also, for pg-pool, there are breaking change ideas queued up, like returning client wrappers that stop working when they’re returned to the pool; those would also be waiting on a new major pg version eventually, so maybe they can be revisited too for this major.
@vitaly-t Your “generic” package isn’t libpq-compatible. It’s MongoDB-compatible. release(true) is completely unrelated to what you quoted and I don’t feel like wasting time expanding on it for you.
Is there any update on this? We get this warning on all our Lambda invocations and it's quite noisy.
How is the proposed upgrade to [email protected] progressing? Is there an issue I can follow for updates on that?
Does anyone know of a workaround? Would it be practical to update the 2.x branch of pg-types to update its postgres-bytea without doing the full pg@9 update for node-postgres, if that is not expected soon?
Want to do a bump in this. We've our monitor system flooded with console.error reporting this error, since we're using BYTEA a lot. Any chance to have this upgraded?
Hey this issue is causing crashes for me (although due to an obscure & annoying mesh of dependencies that isn't really pg's fault). There is a bug in some versions of node: nodejs/node#53075 that mean that the Buffer() deprecation warning instead crashes in WASM environments.
I'm using vercel (whose current node version (20.15.X) is currently vulnerable to the above bug and neondatabase that uses pg as a dependency.
Is there any idea when this might get addressed? I'll probably be looking for alternative solutions on my end anyway but thought it was worth bumping
We still get this warning on all our Lambda invocations and it's quite noisy.
If it is too difficult to update pg-type, could this project perhaps add a workaround like fedecastelli suggested above? I'm hesitant to do that in my own code as I don't understand the risks and tradeoffs involved in changing how pg parses BYTEA (which is why I'm using a library!)
pg won’t do it until the next major release because it includes breaking changes, but there’s no reason anyone creating new projects shouldn’t use the latest pg-types (and for non-new projects, no reason most people shouldn’t upgrade ahead of time).
I’m not sure if pg-types has a changelog separate from its commits and from pg’s – it should probably get one – but I believe the breaking changes are:
removed Node 8 support (not a breaking change relative to pg 8, which requires Node ≥16)
added range type parsing (if you don’t use range types, no change)
removed date parsing (if you currently rely on the SQL date type being parsed to Date, you should fix that)
removed lib/arrayParser.js and the arrayParser export (you probably aren’t using this, but its functionality should be imported from postgres-array)
a few things related to binary parsers (pg doesn’t support binary mode yet, so you almost certainly aren’t using the binary parsers)
Footnotes
The workaround is not really possible to do at the library level without some level of breaking change because of how pg-types makes global mutable state part of its public API – specifically, a level of breaking change that’s not worth it for this backport. ↩
[email protected] is out within the existing version constraints of pg 4.4.0 through 8.16.3 (latest) → pg-types 1.7.0 through 2.2.0 → postgres-bytea@~1.0.0 (thank you @bendrucker!), so all you need now is npm update postgres-bytea.
Activity
brianc commentedon Dec 3, 2020
Oh yes I need to upgrade. I know there are some backwards incompatible changes which is why I've waited so long. I think I should schedule a [email protected] upgrade for some time in January and make it a bundle of breaking changes. @charmander got any other breaking changes that come to mind? I'd like to deprecate the "query queue" concept in 9.0 - add a deprecation warning if you queue a query while another one is still in flight. Thoughts?
charmander commentedon Dec 3, 2020
@brianc All of that sounds good!
BigIntbecoming the default value type forBIGINTis also something pg-types might be about to get. If you’re looking to bundle more breaking changes (I guess it’s good for getting people to look at the changelog!), thoughts on these?typesquery option (it’s an array of OIDs, but also aTypeParser) into incoming and outgoing typessslmode=…behaviour (sslmode=require in connection string breaks with self signed certificate #2375, Fix 'Error: invalid sslmode value: "true"' in native mode #2299) + service configuration (service= connection parameter #416)ssl=1and AddPGSSLMODE=no-verifysupport to opt-out of rejecting self-signed certs #2195We can open issues to discuss them if they sound worth talking about!
Also, for pg-pool, there are breaking change ideas queued up, like returning client wrappers that stop working when they’re returned to the pool; those would also be waiting on a new major pg version eventually, so maybe they can be revisited too for this major.
charmander commentedon Dec 9, 2020
@vitaly-t Your “generic” package isn’t libpq-compatible. It’s MongoDB-compatible.
release(true)is completely unrelated to what you quoted and I don’t feel like wasting time expanding on it for you.RichardBradley commentedon Nov 14, 2022
Is there any update on this? We get this warning on all our Lambda invocations and it's quite noisy.
How is the proposed upgrade to [email protected] progressing? Is there an issue I can follow for updates on that?
Does anyone know of a workaround? Would it be practical to update the 2.x branch of
pg-typesto update itspostgres-byteawithout doing the fullpg@9update fornode-postgres, if that is not expected soon?thmang82 commentedon Jan 15, 2023
Any plans to fix this?
Whenever BYTEA is used on a node:lts image (node 18), I get an error log. Not so nice :-(
70nyIT commentedon May 16, 2024
Want to do a bump in this. We've our monitor system flooded with
console.errorreporting thiserror, since we're using BYTEA a lot. Any chance to have this upgraded?danny-hunt commentedon Jul 22, 2024
Hey this issue is causing crashes for me (although due to an obscure & annoying mesh of dependencies that isn't really pg's fault). There is a bug in some versions of node: nodejs/node#53075 that mean that the Buffer() deprecation warning instead crashes in WASM environments.
I'm using vercel (whose current node version (20.15.X) is currently vulnerable to the above bug and neondatabase that uses pg as a dependency.
Is there any idea when this might get addressed? I'll probably be looking for alternative solutions on my end anyway but thought it was worth bumping
charmander commentedon Jul 22, 2024
@danny-hunt You can add the newer version of pg-types as a dependency, then pass it to pg as the
typesproperty of the config.fedecastelli commentedon Jul 26, 2024
Hi there!
While I wait for a new release to fix how BYTEA is handled in node, I added these lines of code to my pg client initialization:
This change prevents an error from being logged every time a BYTEA is read. I hope this helps!
charmander commentedon Jul 27, 2024
Also a good workaround. If you want to be compatible with the defaults in terms of producing a
Bufferinstead of a0x…string, it’s(Note that the default parser is compatible with PostgreSQL <9.0, but this one is not.)
RichardBradley commentedon Dec 16, 2025
Is there any update on this?
We still get this warning on all our Lambda invocations and it's quite noisy.
If it is too difficult to update pg-type, could this project perhaps add a workaround like fedecastelli suggested above? I'm hesitant to do that in my own code as I don't understand the risks and tradeoffs involved in changing how
pgparsesBYTEA(which is why I'm using a library!)charmander commentedon Dec 16, 2025
@RichardBradley I’ll look into fixing it for pg 8 the right way1, by opening a pull request to create
[email protected]; note that it might not be released in pg for a long time even if it is accepted[email protected]. But really, do this: #2426 (comment)pg won’t do it until the next major release because it includes breaking changes, but there’s no reason anyone creating new projects shouldn’t use the latest pg-types (and for non-new projects, no reason most people shouldn’t upgrade ahead of time).
I’m not sure if pg-types has a changelog separate from its commits and from pg’s – it should probably get one – but I believe the breaking changes are:
dateparsing (if you currently rely on the SQLdatetype being parsed toDate, you should fix that)lib/arrayParser.jsand thearrayParserexport (you probably aren’t using this, but its functionality should be imported from postgres-array)Footnotes
The workaround is not really possible to do at the library level without some level of breaking change because of how pg-types makes global mutable state part of its public API – specifically, a level of breaking change that’s not worth it for this backport. ↩
charmander commentedon Dec 17, 2025
[email protected] is out within the existing version constraints of pg 4.4.0 through 8.16.3 (latest) → pg-types 1.7.0 through 2.2.0 → postgres-bytea@~1.0.0 (thank you @bendrucker!), so all you need now is
npm update postgres-bytea.chore(deps): bump postgres-bytea to 1.0.1 to drop Buffer() deprecation (
chore(deps): bump postgres-bytea to 1.0.1 to drop Buffer() deprecation (