From 96d95a50fc40c1afd8b31800f63c6688484b6f93 Mon Sep 17 00:00:00 2001 From: Ada Date: Wed, 4 Feb 2026 15:24:14 -0800 Subject: [PATCH] fix: resolve ReadableStream in simulator so LangGraph runs on RN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add src/polyfills.ts as the first executed module; inject ReadableStream/WritableStream/TransformStream via web-streams-polyfill and ponyfill fallback - Import polyfills at the top of App.tsx so globals are set before any LangChain/LangGraph code loads - Add assets/images/icon.png to fix Metro “Asset not found” for icon --- App.tsx | 1 + assets/images/icon.png | Bin 0 -> 70 bytes src/polyfills.ts | 15 +++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 assets/images/icon.png create mode 100644 src/polyfills.ts diff --git a/App.tsx b/App.tsx index cecce47..c17ecbc 100644 --- a/App.tsx +++ b/App.tsx @@ -4,6 +4,7 @@ * Main application component with authentication routing. * Shows loading screen while restoring auth state. */ +import './src/polyfills'; import React from 'react'; import { Buffer } from 'buffer'; diff --git a/assets/images/icon.png b/assets/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f37764b1f7606623616dcdc169cc858273ea2d94 GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9xZYBRYe;|OLfu)tPp=D){ QB2a?C)78&qol`;+0Lr!y6951J literal 0 HcmV?d00001 diff --git a/src/polyfills.ts b/src/polyfills.ts new file mode 100644 index 0000000..c9c8fde --- /dev/null +++ b/src/polyfills.ts @@ -0,0 +1,15 @@ +/** + * Polyfills that must run before any other app code (including LangChain/LangGraph). + * This file is imported as the very first line in App.tsx so that ReadableStream + * exists before @langchain/core or @langchain/langgraph are loaded. + */ +import 'web-streams-polyfill'; + +// Ensure globalThis has ReadableStream (main polyfill may not patch in RN/Metro) +const g = typeof globalThis !== 'undefined' ? globalThis : (typeof global !== 'undefined' ? global : (typeof self !== 'undefined' ? self : {})); +if (typeof (g as any).ReadableStream === 'undefined') { + const ponyfill = require('web-streams-polyfill/dist/ponyfill.js'); + (g as any).ReadableStream = ponyfill.ReadableStream; + (g as any).WritableStream = ponyfill.WritableStream; + (g as any).TransformStream = ponyfill.TransformStream; +}