Skip to content

Web: importing StreamdownText crashes at module load (createWorkletRuntime called at module scope) #27

Closed

Description

@MaryanPrydatko

Description

src/worklets/remendWorklet.ts calls createWorkletRuntime at module scope:

const remendRuntime = createWorkletRuntime({ name: 'remend-processor' });

react-native-worklets' web build implements the runtime API family (createWorkletRuntime, scheduleOnRuntime, ...) as deliberately throwing stubs, and react-native-streamdown ships no web fork of its own to avoid them. So on react-native-web, the first import of StreamdownText throws at module load and takes the whole app down before anything renders.

Reproduction

Expo (or any react-native-web) app, web target:

import { StreamdownText } from 'react-native-streamdown';
// rendering <StreamdownText markdown="hi" /> never gets a chance —
// the import itself throws: createWorkletRuntime is not available on web

This took down chat in our production web app (the same JS bundle serves iOS, Android and web via Expo Router).

Suggested fix

Guard the runtime behind Platform.OS === 'web' and run remend on the JS thread there, delivering the result through scheduleOnRN (whose web implementation is a microtask) so both platforms use the same delivery primitive. remend is pure JS. Native behavior stays untouched.

We are running exactly this as a patch in production and it works: streaming repair renders fine on web. PR incoming.

Activity

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