Skip to content

Event handling bug + live streaming inside iframe #86

Open

Description

@zk1tty

Issue

  1. At anime-watch-hub sample, iframe sandbox was not allowed to render the browser live stream, which requires run JavaScript.
  2. return value data type was old and function didn't work now.
    https://v0-animefinder.vercel.app/
Image

The fix

Before

Image

After

Image
  1. sandbox attirbute
  • remove sandbox="allow-same-origin" attribute.
  • added allow-scripts and allow-forms to the sandbox attribute. The live viewer from TinyFish needs JavaScript to render the browser stream.
  1. amend /run-see streaming API endpoint event handling types

    Before (wrong) After (correct)
    data.streamingUrl data.streaming_url on STREAMING_URL event
    data.type === 'STATUS', data.message data.type === 'PROGRESS', data.purpose
    data.type === 'COMPLETE', data.resultJson data.type === 'COMPLETE', data.result + data.status
    No failure handling data.status === 'failed' → error state with data.error.message

Comment

I only tried this folder, but I assume same issues can happen at other folders tool.
Highly recommended to review and adjust to new event types on /run-sse endpoints.
doc: https://docs.tinyfish.ai/key-concepts/endpoints#streaming-/run-sse

cc: @simantak-dabhade

Activity

  1. changed the title [-]Unlock live streaming inside iframe[/-] [+]Event handling bug + live streaming inside iframe[/+] on Mar 19, 2026
  2. added a commit that references this issue on Mar 30, 2026
  3. JiwaniZakir commented on Mar 31, 2026

    @JiwaniZakir

    The iframe issue is a straightforward sandbox policy misconfiguration — allow-same-origin alone restricts script execution, which breaks any JavaScript-dependent renderer like TinyFish's live stream viewer. The /run-sse event handling mismatch points to the client code being written against an older version of the API contract; the field renames (streamingUrl → streaming_url, STATUS → PROGRESS, resultJson → result) and the addition of a failed status suggest the SSE payload schema was updated server-side without corresponding client updates in the sample. As the reporter notes, any other samples using /run-sse likely share the same stale event handler pattern and should be audited against the current schema documented at https://docs.tinyfish.ai/key-concepts/endpoints#streaming-/run-sse.

  4. Hotragn commented on Aug 4, 2026

    @Hotragn

    I ran the repo-wide review @zk1tty recommended here. The prediction held — three recipes still have the same defect shape (a consumer waiting on an event type or field that no producer emits):

    • tinyskills — hooks/use-generation.ts:202 handles source_streaming, but app/api/scrape-sources/route.ts never emits it. Live preview never renders. (Featured recipe with a live demo.)
    • stay-scout-hub — src/lib/api/area-search.ts:84 handles event.type === 'STATUS', but api/research-area/route.ts emits only CONNECTED, SCREENSHOT, COMPLETE, ERROR. Progress text never updates. This one survived the SDK migration in Migration stay-scout-hub to Tinyfish SDK #223: the route was updated to EventType.STREAMING_URL / event.streaming_url, the client handler wasn't.
    • competitor-analysis — app/api/scrape-pricing/route.ts:369 reads event.streamingUrl off the raw SDK event; the SDK emits streaming_url, so the guard never fires and the preview is dead end-to-end.

    anime-watch-hub (the folder in this issue) is fine now — #164 fixed it — which is why this stayed quiet.

    The two dead-branch cases are statically detectable: the set of event types a client compares against should be a subset of the types its recipe emits. I've opened #243 proposing a small conformance check for exactly that, plus the SDK snake_case boundary, so this class of bug stops reaching main instead of being re-found by hand each time.

    Taking these three fixes unless someone's already on them — will send one small PR per recipe so they're independently reviewable.

  5. Hotragn commented on Aug 4, 2026

    @Hotragn

    Fixes are up, one PR per recipe so they can be reviewed and reverted independently:

    • Remove dead live-preview path from tinyskills #245 — tinyskills: removes the dead source_streaming path. Worth a look at the reasoning: this recipe moved to Fetch, which has no browser session, so there is no streaming URL to surface. Making the "Watch live" link work again would mean moving back to the metered Agent endpoint, which is a product call rather than a bug fix — so this removes the vestigial path instead of inventing an event.
    • Fix stay-scout-hub progress text never updating #246 — stay-scout-hub: the route was dropping PROGRESS, the event that carries the narration. It now forwards it as the STATUS the client already expects, and the client also handles CONNECTED so the opening message lands.
    • Fix competitor-analysis live browser preview never appearing #247 — competitor-analysis: drops the any cast and reads the stream through the SDK's EventType/RunStatus. Also fixes two stale reads that were masked by fallbacks ('STEP', resultJson), and moves error handling into the COMPLETE branch since there is no ERROR event type.

    Each verified with tsc --noEmit (and npm run lint where the recipe's lint config still works — stay-scout-hub has eslint@^9 with no eslint.config.js, so its lint script is broken on main independently of this).

    Once these land, every recipe in the repo is clean against the check in #244. Since @zk1tty's original folder (anime-watch-hub) was fixed in #164, this issue can close with #245–#247 — happy to leave it open if you'd rather track the check separately.

  6. zk1tty commented on Aug 4, 2026

    @zk1tty
    ContributorAuthor

    Hi @Hotragn thank you for picking up these!
    I guess @simantak-dabhade is the person in charge of PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions