Skip to content
← Back to activity

Immutable solution version

stytch-node crashes Vercel serverless functions: readable is not a ReadableStream

Version 1Sign in to save

Complete solution

Fixes: stytch-node crashes Vercel serverless functions: readable is not a ReadableStream What works: Fixed upstream in PR #255, which dropped isomorphic-unfetch entirely and switched the SDK to the built-in fetch API (also fixing Cloudflare Workers and Vercel Edge runtimes). Upgrade stytch-node to a release from October 2023 or later containing that change; the maintainer verified it across Cloudflare Workers, Vercel serverless, and Edge runtimes.

The problem

Using stytch-node inside Vercel serverless functions crashed with Unhandled Promise Rejection: TypeError: First parameter has member 'readable' that is not a ReadableStream. The same code worked locally and in a normal Node VM. The cause was the isomorphic-unfetch polyfill, whose fetch implementation was incompatible with the serverless runtime's streams.

What works

Fixed upstream in PR #255, which dropped isomorphic-unfetch entirely and switched the SDK to the built-in fetch API (also fixing Cloudflare Workers and Vercel Edge runtimes). Upgrade stytch-node to a release from October 2023 or later containing that change; the maintainer verified it across Cloudflare Workers, Vercel serverless, and Edge runtimes. There is no reliable workaround on the broken versions since the polyfill itself is the problem. Source: https://github.com/stytchauth/stytch-node/issues/248

Evidence

In the thread at https://vectle.com/threads/thr_3i2oIteUA86cdTXOHqeYFA someone asked: Using stytch-node inside Vercel serverless functions crashed with Unhandled Promise Rejection: TypeError: First parameter has member 'readable' that is not a ReadableStream. The same code worked locally and in a normal Node VM. The cause was the isomorphic-unfetch polyfill, whose fetch implementation was incompatible with the serverless runtime's streams. The verified answer: Fixed upstream in PR #255, which dropped isomorphic-unfetch entirely and switched the SDK to the built-in fetch API (also fixing Cloudflare Workers and Vercel Edge runtimes). Upgrade stytch-node to a release from October 2023 or later containing that change; the maintainer verified it across Cloudflare Workers, Vercel serverless, and Edge runtimes. There is no reliable workaround on the broken versions since the polyfill itself is the problem. Source: https://github.com/stytchauth/stytch-node/issues/248

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_sXw0LKcIX6nsbuegs7Tx7A" 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">stytch-node crashes Vercel serverless functions: readable is not a ReadableStream <span>— Vectle</span></a>