Repository navigation
node:http: extract the half-close of socket.end() into JSNodeHTTPServerSocket::halfClose() - #44243
Conversation
…erSocket::halfClose() The pause, shutdown and resume sequence of the native end() moves into a member function, unchanged. A later change calls it from a second place.
|
Status
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: oven-sh/bun/.coderabbit.yaml Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. WalkthroughThe empty-buffer normal-end path now calls ChangesHTTP server socket half-close
Suggested reviewers: Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The half-close extraction has no identified behavior regression and is ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
Problem
end()of thenode:httpserver socket holds its half-close sequence inline (jsFunctionNodeHTTPServerSocketEnd,src/jsc/bindings/node/JSNodeHTTPServerSocketPrototype.cpp:313).socket.end()that waited for buffered bytes. A second copy can drift from the first.Fix
JSNodeHTTPServerSocket::halfClose(). The move is verbatim: pause the reads, write withendedset (this sends the FIN), resume the reads.jsFunctionNodeHTTPServerSocketEndcalls it and returns its value, as before.us_socket_pauseandus_socket_resumedeclarations from the prototype file. They have no user there now.Behaviour change: none
Background
socket.end()in Node is a half-close.Downsides
halfClose():jsFunctionNodeHTTPServerSocketEndgoes from 633 to 671 bytes, and from 192 to 191 instructions..text(58148853 bytes) and the binary (80832072 bytes) do not change.Notes
All runs are on Linux x64, on release builds of main 9f70da0 and of this commit 7c98ad5.
test/js/node/http/node-http-server-socket-end-drain.test.tstest/js/node/http/node-http-connect.test.tstest/js/node/http/node-http-backpressure.test.tstest/js/node/http/node-http-pinned-write.test.tstest/js/node/http/node-http-server-close-drain.test.tstest/js/node/http/node-http.test.tstest/js/node/test/parallel/(test-http-*,test-https-*) that start a server and end, pipeline or write on its socketA debug build with ASAN of this commit alone did not run. The same suites ran on a debug build with ASAN of the second PR of the stack, which contains this change. They pass there, apart from three timeouts from the load of the host. Each of those three tests passes alone. #44244 has the list.
Method for the sizes:
llvm-nm -Sandllvm-objdump -donbun-profile,llvm-size -Afor.text. Every other function of the socket binding and ofHttpContexthas the same bytes in both builds.