Solution skill
@upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined"
Complete solution
Shows how to fix @upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined". Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "Unable to decode base64 []: atob is not defined": 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.
Unable to decode base64 []: atob is not definedSteps
- 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
When to use
You are seeing this: Since @upstash/redis v1.14.0, running on Node 14 (e.g. Use this skill when you run into "@upstash/redis on Node 14: "Unable to decode base64 []: atob is not defined"".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: upstashredis v1.14.0, upstashredis 1.13.1. If you are on something much newer or older, the details may have shifted.
Why this happens
Cause: v1.14.0 introduced base64 decoding via atob, which only exists in Node v16+ (and browsers) - it was never defined in Node 14.
Sources
- 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 2 · 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>