planetscale/database-js

older node.js doesn't have a btoa function

brianleroux opened this issue · 4 comments

unfortunately AWS Lambda runs Node 16.x for the moment; cooked a little workaround for now in case this is helpful for someone

Screen Shot 2022-08-18 at 2 26 51 PM

Node 16 should have btoa. Are you sure this isn't running an even older Node 14 version?

$ node -v                          
v16.13.2
$ node -e "console.log(btoa('hi'))"
aGk=

$ node -v                            
v14.15.4
$ node -e "console.log(btoa('hi'))"
ReferenceError: btoa is not defined

omfg I was using a hack project that fell out of date! don't mind me nothing to see here =P

great work on this feature / smoking fast even w a cold start. been waiting to say that about sql on lambda for seven years.

Some further context; would be worth revisiting btoa after all.

https://twitter.com/addaleax/status/1560386570062028804?t=M2R4ilUfhp2ls0Qu20BwTQ&s=19

Thanks for those details. We can reliably use the implementations of btoa in browsers and in Node's standard library to base64 encode the Authorization header value for transport to the servers to which this library connects. We'll revisit if there's a problem in the future. Thanks!