Skip to content

Conversation

mcollina
Copy link
Member

Summary

  • Remove eager promise creation from llhttp WebAssembly module loading
  • Make llhttp loading truly lazy by calling lazyllhttp() only when needed
  • Replace async WebAssembly methods with synchronous constructors
  • Eliminate all promise handling from the llhttp loading path

Changes

This PR makes two key improvements to the llhttp WebAssembly module loading:

  1. Truly lazy loading: Remove the eager llhttpPromise = lazyllhttp() call at module initialization. Instead, call lazyllhttp() only when the first HTTP/1.1 connection is established.

  2. Synchronous loading: Replace WebAssembly.compile() and WebAssembly.instantiate() with their synchronous counterparts new WebAssembly.Module() and new WebAssembly.Instance().

Benefits

  • No eager promise creation: Eliminates the need for .catch() or .then(null, noop) handlers
  • Simpler code: Removes async/await from the loading path entirely
  • Better performance: Synchronous WebAssembly loading is typically faster than async
  • Cleaner initialization: No promise handling at module load time

Test plan

  • Existing tests pass
  • Linting passes
  • No breaking changes to public API

🤖 Generated with Claude Code

mcollina and others added 2 commits July 16, 2025 21:52
Remove eager promise creation and load llhttp WebAssembly module only when needed.

Previously, the llhttp WebAssembly module was loaded eagerly at module initialization
with a .catch() handler. This change makes the loading truly lazy by calling
lazyllhttp() only when the first HTTP/1.1 connection is established.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Remove async/await from llhttp WebAssembly module loading by using synchronous
WebAssembly.Module and WebAssembly.Instance constructors instead of the async
WebAssembly.compile() and WebAssembly.instantiate() methods.

This eliminates the need for promise handling entirely and makes the code
simpler and more direct.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit f0b40bd into main Jul 17, 2025
32 of 34 checks passed
@mcollina mcollina deleted the refactor/lazy-llhttp-loading branch July 17, 2025 09:42
@github-actions github-actions bot mentioned this pull request Jul 18, 2025
@JoshMock JoshMock mentioned this pull request Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants