Skip to content

wasm: add experimental browser runtime and SDK - #12429

Draft
edsiper wants to merge 40 commits into
masterfrom
wasm-browser-sdk
Draft

edsiper wants to merge 40 commits into
masterfrom
wasm-browser-sdk

Conversation

@edsiper

@edsiper edsiper commented Sep 17, 2026

Copy link
Copy Markdown
Member

Fluent Bit currently depends on native facilities that are unavailable in a browser. This adds an experimental Emscripten build profile and browser SDK that run the engine in workers, ingest application records, and export through browser Fetch.

The SDK supports start/stop/restart, bounded command admission, configuration assets, opt-in IndexedDB storage, namespace locking, checkpoint recovery, and status counters. push() acknowledges input acceptance, not remote delivery. Persistent checkpoints require a stopped engine; failed checkpoints block restart until recovery succeeds.

Scope

  • Pin Emscripten 6.0.9 and build selected browser-compatible plugins with Lua 5.4, OpenSSL helpers, and virtual filesystem support.
  • Adapt engine lifecycle and legacy/NG HTTP clients to Fetch, including cancellation and rejection of unsupported browser modes.
  • Add the SDK, TypeScript declarations, browser demo, startup/storage fault tests, and release/ASan CI jobs.
  • Reject dedicated threaded inputs, cap the SDK pthread pool, and use cooperative child shutdown on startup failure. Repeated testing showed sequential startup alone was insufficient.
  • Include Lua sparse-table and SQL string-boundary fixes found during validation.

Bundled changes are isolated in library commits: lib/flb_libco (fiber backend), lib/monkey (protocol/event/timer portability), and lib/chunkio (virtual filesystem/storage support). Related upstream work: flb_libco #14, Monkey #448, ChunkIO #116.

Validation

Local validation passed on Linux with Emscripten 6.0.9 and Chromium 151:

  • Release and ASan builds; 17 release and 19 ASan CTests.
  • Real-browser SDK and full demo suites in both configurations, including HTTP/Loki/OTLP, Lua, persistent replay, injected checkpoint failure/recovery, and teardown.
  • 108 startup-fault cases across repeated release/ASan runs after cooperative cleanup was added.
  • 20 Node contract tests, TypeScript checking, and 13 Python browser-harness tests.
  • Seven focused native input/routing CTests.
  • Lua/HTTP integration: 36 cases normally and with strict Valgrind. Native stdout/input-routing integration: 14 cases normally and with strict Valgrind.

Focused integration commands:

tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/filter_lua tests/integration/scenarios/out_http -q
VALGRIND=1 VALGRIND_STRICT=1 tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/filter_lua tests/integration/scenarios/out_http -q
tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/out_stdout -q
VALGRIND=1 VALGRIND_STRICT=1 tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/out_stdout -q

Full PR-range commit-prefix lint and a local merge check against fetched master pass. Hosted CI results are pending. Build and browser reproduction commands are in the browser documentation.

Draft / production gates

The API remains experimental. It requires a secure, cross-origin-isolated browser context and trusted application configuration. Native builds retain their existing runtime model.

Outstanding work includes end-to-end backlog budgets, engine delivery/drop observability, crash-safe delivery semantics, real quota/eviction/corruption/upgrade testing, Firefox/WebKit/mobile and production CSP/bundler qualification, long-running lifecycle/pressure tests, and reproducible release/security processes. Default ASan passes; optional stack-use-after-return mode still has the documented toolchain cleanup limitation. This draft does not claim production readiness.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant