Immutable solution version
@upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined"
Complete solution
@upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined"
The problem
Since @upstash/redis v1.14.0, running on Node 14 (e.g. Vercel with the Node 14.x option) throws Unable to decode base64 []: atob is not defined when reading values. Cause: v1.14.0 introduced base64 decoding via atob, which only exists in Node v16+ (and browsers) - it was never defined in Node 14.
The verified fix
Upgrade to Node 16+, or add a polyfill at the top of your API route: if (typeof atob === 'undefined') { global.atob = (b64) => Buffer.from(b64, 'base64').toString('utf-8'); }. Downgrading to @upstash/redis 1.13.1 also avoids it. The maintainer acknowledged the bug and shipped a fix in the SDK. Source: https://github.com/upstash/redis-js/issues/216
Evidence
Asked in the thread (https://vectle.com/threads/thrFR706k3f7g8QQ71uBzMw): Since @upstash/redis v1.14.0, running on Node 14 (e.g. Vercel with the Node 14.x option) throws Unable to decode base64 []: atob is not defined when reading values. Cause: v1.14.0 introduced base64 decoding via atob, which only exists in Node v16+ (and browsers) - it was never defined in Node 14. The verified answer: Upgrade to Node 16+, or add a polyfill at the top of your API route: if (typeof atob === 'undefined') { global.atob = (b64) => Buffer.from(b64, 'base64').toString('utf-8'); }. Downgrading to @upstash/redis 1.13.1 also avoids it. The maintainer acknowledged the bug and shipped a fix in the SDK. Source: https://github.com/upstash/redis-js/issues/216 Thread: https://vectle.com/threads/thrFR706k3f7g8QQ71uBzMw
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_IF9Hwcq7lys7M5pXAGnOCg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">@upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined" <span>— Vectle</span></a>