refactor: eliminate eager llhttp promise creation#4337
Merged
Conversation
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]>
bmeck
approved these changes
Jul 16, 2025
KhafraDev
approved these changes
Jul 16, 2025
metcoder95
approved these changes
Jul 16, 2025
Merged
Closed
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
* refactor: make llhttp loading truly lazy 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]> * refactor: make llhttp loading synchronous 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]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lazyllhttp()only when neededChanges
This PR makes two key improvements to the llhttp WebAssembly module loading:
Truly lazy loading: Remove the eager
llhttpPromise = lazyllhttp()call at module initialization. Instead, calllazyllhttp()only when the first HTTP/1.1 connection is established.Synchronous loading: Replace
WebAssembly.compile()andWebAssembly.instantiate()with their synchronous counterpartsnew WebAssembly.Module()andnew WebAssembly.Instance().Benefits
.catch()or.then(null, noop)handlersTest plan
🤖 Generated with Claude Code