Fix streaming resolveSuspense: use callFn instead of eval string interpolation

The previous K.eval() approach double-escaped backslashes in SX source
strings, breaking the \/ → / unescaping that the server serializer adds
for HTML safety. Using K.callFn() passes strings directly as arguments,
bypassing the escaping problem entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 12:35:37 +00:00
parent 7d798be14f
commit 1783f4805a
2 changed files with 4 additions and 2 deletions

View File

@@ -700,8 +700,9 @@
K.eval("(handle-popstate " + scrollY + ")");
});
// Wire up streaming suspense resolution
var _resolveFn = K.eval("resolve-suspense");
Sx.resolveSuspense = function(id, sx) {
try { K.eval('(resolve-suspense "' + id.replace(/"/g, '\\"') + '" "' + sx.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '")'); }
try { K.callFn(_resolveFn, [id, sx]); }
catch(e) { console.error("[sx] resolveSuspense error:", e); }
};
// Drain any pending resolves that arrived before boot