Skip to content

wasm: add experimental browser runtime and SDK - #12429

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

edsiper wants to merge 42 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). These updates are required, not optional: flb_libco #14, Monkey #448, and ChunkIO #116 have all merged upstream. Their bundled changes must accompany the Fluent Bit integration. The browser build additionally cross-compiles SHA-256-pinned OpenSSL 3.5.8, libyaml 0.2.5, and portable Lua 5.4.9 with Emscripten 6.0.9. The installed SDK is not patched.

Validation — refreshed 2026-09-19

Fresh, isolated source worktrees on Linux; official Emscripten 6.0.9, Node 24.19.0, Chromium 151, Valgrind 3.23.0. No unrelated files from the development checkout are included.

Clean-checkout CI exposed a missing Lua test harness header: previous local native builds had generated it in the source tree. The WASM Lua target now generates its own build-tree header. This refresh changes only that test-build interface and prerequisite documentation; runtime and bundled-library sources are unchanged.

Completed locally:

  • Fresh optimized and ASan builds: 17/17 and 19/19 CTests passed, without a native-generated Lua harness.
  • Real Chromium SDK, pthread-startup fault, and full HTTPS demo suites passed in both configurations, including HTTP/Loki/OTLP, Lua, persistence/recovery, cancellation, and teardown.
  • 54 pthread-startup fault cases passed (27 per configuration).
  • 20 Node contract tests; TypeScript 5.9.3 strict consumer check; 15 Python browser-harness tests plus 6 subtests passed.
  • Fresh native build: 9/9 focused Lua/SQL, routing/chunk, YAML, backlog, and output CTests passed.
  • Native integration: 99 passed normally (including six startup-helper tests).
  • Lua and SQL unit tests passed strict Valgrind: zero errors, no remaining allocations.

Pending: the fresh full native strict-Valgrind integration run and hosted CI on the updated head. Previous validation passed focused native integrations under strict Valgrind; this section will be updated with the fresh result rather than treating old results as a new pass.

Focused native commands (set FLUENT_BIT_BINARY when using an external build):

tests/integration/.venv/bin/python -m pytest tests/integration/test_fluent_bit_manager_startup.py tests/integration/scenarios/filter_lua tests/integration/scenarios/out_http tests/integration/scenarios/out_stdout tests/integration/scenarios/in_storage_backlog tests/integration/scenarios/in_http tests/integration/scenarios/internal_http_server -q
VALGRIND=1 VALGRIND_STRICT=1 tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/filter_lua tests/integration/scenarios/out_http tests/integration/scenarios/out_stdout tests/integration/scenarios/in_storage_backlog tests/integration/scenarios/in_http tests/integration/scenarios/internal_http_server -q

Full PR-range commit-prefix lint and whitespace checks pass, all new commits carry DCO sign-offs, and a merge check against fetched master is clean. This update is a normal fast-forward push; no published history was rewritten.

The previous hosted native matrix also failed flb-rt-out_s3 in ordered_shared_upload_retries_safely with SIGSEGV. The focused local rerun passed, but that does not establish a fix; no unrelated S3 change is included. Hosted CI on this head must still be checked before merge.

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.

Generate the internal-test harness for the standalone WASM Lua target.
Native internal tests are disabled by the browser profile, so a clean
checkout cannot rely on their source-tree generated header.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
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