Skip to content

#27317 — Code blocks fail to render when syntax highlighting worker initialization fails #861

@ElioNeto

Description

@ElioNeto

Description

Summary

Code blocks fail to render when the worker-based syntax highlighting pipeline fails to initialize. The worker pool remains uninitialized (initialized: false, empty language registry) and may not emit a reliable error event. As a result, no highlighted HTML is generated and code blocks do not render, causing dependent UI elements such as expand/collapse to break due to missing content.

This has been observed in Android production builds when the OpenCode web UI is loaded inside an Expo React Native WebView. It does not reproduce in desktop browsers or Android debug/emulator builds.

Observed Behavior

  • Worker pool remains uninitialized (initialized: false)
  • Empty language registry
  • No reliable error event emitted
  • Syntax highlighting does not render
  • Code blocks do not render
  • Expand/collapse UI appears broken due to missing content

Expected Behavior

Worker initialization failure should trigger a fallback to main-thread highlighting instead of leaving the system in an uninitialized state.

Proposed Fix

Wrap worker initialization in a Promise.race between:

  • successful initialization
  • worker error event
  • timeout

If worker initialization does not successfully complete before error/timeout, fallback to main thread

Scope

No behavior change in environments where workers function correctly. This only adds a fallback path for initialization failure cases.

Plugins

None

OpenCode version

1.14.48

St

[Truncado — 3331 chars totais]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmedium

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions