From 016315afbcb707b7ee5048c194bdaad04ec5397e Mon Sep 17 00:00:00 2001 From: Dsm0 Date: Wed, 28 Jan 2026 17:06:16 -0800 Subject: [PATCH] fix 'Maximum call stack size exceeded' --- packages/core/util.mjs | 9 +++++++-- website/src/repl/useReplContext.jsx | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/core/util.mjs b/packages/core/util.mjs index 915a2cb77..c38c8e05f 100644 --- a/packages/core/util.mjs +++ b/packages/core/util.mjs @@ -339,8 +339,13 @@ export function uniqsortr(a) { export function unicodeToBase64(text) { const utf8Bytes = new TextEncoder().encode(text); - const base64String = btoa(String.fromCharCode(...utf8Bytes)); - return base64String; + let binaryString = ''; + const chunkSize = 0x8000; + for (let i = 0; i < utf8Bytes.length; i += chunkSize) { + const chunk = utf8Bytes.subarray(i, i + chunkSize); + binaryString += String.fromCharCode.apply(null, chunk); + } + return btoa(binaryString); } export function base64ToUnicode(base64String) { diff --git a/website/src/repl/useReplContext.jsx b/website/src/repl/useReplContext.jsx index 0d44eedfe..fc4ab6e10 100644 --- a/website/src/repl/useReplContext.jsx +++ b/website/src/repl/useReplContext.jsx @@ -109,7 +109,12 @@ export function useReplContext() { // Get the full buffer content from the editor instead of just the evaluated block const fullBufferCode = editorRef.current?.code || code; setLatestCode(fullBufferCode); - window.location.hash = '#' + code2hash(fullBufferCode); + + try { + window.location.hash = '#' + code2hash(fullBufferCode); + } catch (e) { + console.warn('[useReplContext] Failed to update hash:', e.message); + } setDocumentTitle(fullBufferCode); const viewingPatternData = getViewingPatternData(); setVersionDefaultsFrom(fullBufferCode);