Skip to content

Fix Safari LiteRT chat: undefined is not a function - #10

Merged
Nostromo-618 merged 1 commit into
mainfrom
fix/ai-chat-undefined-function
Aug 8, 2026
Merged

Fix Safari LiteRT chat: undefined is not a function#10
Nostromo-618 merged 1 commit into
mainfrom
fix/ai-chat-undefined-function

Conversation

@Nostromo-618

Copy link
Copy Markdown
Member

Summary

  • Root cause: LiteRT sendMessageStreaming() returns a ReadableStream. _completeOnceLiteRT used for await...of on it. Safari/WebKit often lacks ReadableStream.prototype[Symbol.asyncIterator], so iteration throws undefined is not a function (near '...s of a...') (matches the live Gemma 4 E2B LiteRT failure after sending e.g. "yo man").
  • Fix: Add iterateMessageStream() — prefer async iteration when present, otherwise consume via getReader(). Wire LiteRT streaming through that helper.
  • Regression test: Reader-only stream (no asyncIterator) covering Safari’s shape; existing async-generator mocks still pass.

Test plan

  • pnpm test -- tests/unit/guardrails.spec.ts — 102 passed (includes new Safari stream test)
  • Manual: on Safari (or WebKit), load vdl-ai-chat, select Gemma 4 E2B LiteRT official web (Online), send yo man, confirm streamed reply (no footer/undefined is not a function error)

Made with Cursor

sendMessageStreaming returns a ReadableStream; Safari lacks asyncIterator, so for-await threw "undefined is not a function". Consume via getReader when needed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kilo-code-bot

kilo-code-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • ai-chat.js
  • tests/unit/guardrails.spec.ts

Reviewed by deepseek-v4-pro · Input: 41.4K · Output: 8.5K · Cached: 162K

@Nostromo-618
Nostromo-618 merged commit 0796a64 into main Aug 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant