Repository navigation
perf: skip the req/res prototype switch for app.listen() - #7555
Draft
nigrosimone wants to merge 1 commit into
Draft
nigrosimone wants to merge 1 commit into
nigrosimone wants to merge 1 commit into
Conversation
…p.handle() skips the switch
nigrosimone
marked this pull request as ready for review
October 24, 2026 06:26
nigrosimone
marked this pull request as draft
October 24, 2026 06:27
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.
app.handle()callsObject.setPrototypeOfon req and res for every request. On Node 24 and 26 this still costs about 2.4 us per request, -22% ofapp.handle()for ares.send('Hello World!')(in-process bench, numbers per Node version in expressjs/perf-wg#15).Fix:
app.listen()passes tohttp.createServeranIncomingMessageandServerResponsewithapp.requestandapp.responseas prototype, andapp.handle()skips the switch when the prototype is already the right one. Mounted apps still switch and restore as before. Apps that callhttp.createServer(app)themselves keep the switch.Test:
app.listen()serves a request with no switch (fails without the fix with 2 switches), and a mounted app still sees its own prototypes.