google / google/adk-web

SyntaxError: Unterminated string in JSON when responses are parsed in the Google ADK Dev Front-End

Open
#74 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1k
Forks
267
Avg merge
1d 12h
Merged PRs (30d)
9

Description

![Image](https://github.com/user-attachments/assets/4ab56bcc-d8db-4342-83d6-197ca433a0c8)

![Image](https://github.com/user-attachments/assets/6f1eaeaa-a669-4711-8520-76cf3a851e1a)

I am consistently encountering a `SyntaxError: Unterminated string in JSON` when responses are parsed in the Google ADK auto-generated web app's client side code. The error occurs specifically at **position 4004 (line 1 column 4005)**, indicating that the JSON string being received is truncated.

This issue makes testing difficult from correctly processing the full response from the ADK, as the `JSON.parse` operation fails due to incomplete data.

OS: Windows 11
Python version(python -V): 3.12
ADK version(pip show google-adk): v1.4.1
Google ADK Dev Web App: "adk web --host 0.0.0.0"
Google Chrome

### Steps to Reproduce

1. Access the Google ADK web application "adk web --host 0.0.0.0"
2. Initiate a request that elicits a response from the ADK AND includes information from the RAG which exceeds the 1024 characters. The response from server should include `groundingMetadata` with a reasonable amount of `retrievedContext` information. In other words, the **response should be very long**.
3. Observe the network traffic (e.g., in browser developer tools) for the SSE stream (`/run_sse`).
4. The client-side JavaScript (within `main-JAAWEV7F.js`) attempts to parse the incoming `data:` events as JSON.
5. The `JSON.parse` operation fails with the reported `SyntaxError` at column 4005, indicating a truncated JSON string.

### Expected Behavior

The Google ADK web app should send complete and valid JSON objects within its SSE `data:` events and the message must be shown in the application front-end

### Actual Behavior

The JSON string received via the SSE stream is truncated at approximately 4004 characters, leading to a `SyntaxError: Unterminated string in JSON` during parsing.

### Relevant Information

* **Error Message:**

```
main-JAAWEV7F.js:22 ERROR SyntaxError: Unterminated string in JSON at position 4004 (line 1 column 4005)
at JSON.parse ()
at e. (main-JAAWEV7F.js:91:2736)
at Generator.next ()
at main-JAAWEV7F.js:16:807
at new M (polyfills-B6TNHZQ6.js:17:2237)
at Ze (main-JAAWEV7F.js:16:627)
at Object.next (main-JAAWEV7F.js:91:2638)
at Dl.next (main-JAAWEV7F.js:18:3112)
at xo._next (main-JAAWEV7F.js:18:2795)
at xo.next (main-JAAWEV7F.js:18:2522)
```

I suspect there might be an **internal message size limit** or **buffering issue** within the Google ADK's SSE clientside or backend, causing responses exceeding a certain length (around 4KB in this case) to be prematurely truncated before reaching the client's parsing logic. Ensuring that complete JSON objects are sent for each `data:` event would resolve this problem.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.