Skip to content

server: read the method id uWS resolved, not the method name - #45399

Draft
robobun wants to merge 1 commit into
robobun/5627effc/node-http-rawpacket-methodfrom
robobun/5627effc/serve-method-id-rust
Draft

robobun wants to merge 1 commit into
robobun/5627effc/node-http-rawpacket-methodfrom
robobun/5627effc/serve-method-id-rust

Conversation

@robobun

@robobun robobun commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fix

  • Request::method() returns a Method. The shim asks uWS for the id of the method (uws_req_get_method_id).
  • The 12 arms go, and the Option<Method> parameters with them. So do Method::find(), RouteMethod::specific() and the string fallback in NodeHTTP.cpp.
  • An id that is no Method fails a debug assertion. A release build reads it as GET, as before.
  • Self-reviewed: 33 concerns raised, 32 addressed (Bun.serve: answer 501 to an unknown method and 404 to a router miss, not a closed socket #45396).

Behaviour change: none

Tests that cover this code: test/js/bun/http/bun-serve-routes.test.ts (each of the 36 methods must arrive as req.method), test/js/node/http/node-http.test.ts, test/js/bun/http/serve-http2.test.ts, test/js/bun/http/serve-http3.test.ts, test/js/bun/http/bun-serve-file.test.ts.

Background

Downsides

Notes

@robobun

robobun commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Status

This PR changes no behaviour once #45357 is in. It is a draft until then. #45396 has the reproduction of the bug that this stack fixes.

The stack: #44510, #45396, #45397, #45398, #45399 (draft), #45400 (draft).

@robobun
robobun force-pushed the robobun/5627effc/node-http-rawpacket-method branch from c2b76a4 to de273e4 Compare October 15, 2026 20:32
@robobun
robobun force-pushed the robobun/5627effc/serve-method-id-rust branch from 45d2e2c to 9e5913c Compare October 15, 2026 20:32
@robobun
robobun force-pushed the robobun/5627effc/node-http-rawpacket-method branch from de273e4 to 8b4be0f Compare October 15, 2026 21:45
@robobun
robobun force-pushed the robobun/5627effc/serve-method-id-rust branch from 9e5913c to ed1a9e9 Compare October 15, 2026 21:57
@robobun
robobun force-pushed the robobun/5627effc/node-http-rawpacket-method branch 3 times, most recently from 84f2a1d to c5d8886 Compare October 17, 2026 10:06
@robobun
robobun force-pushed the robobun/5627effc/serve-method-id-rust branch from ed1a9e9 to 41e84b1 Compare October 17, 2026 10:06
Request::method() returns the Method for the id that the parser stored
on the request. A handler runs only for a request that has one, so the
12 lookups that substituted GET, POST or OPTIONS for a name they did not
know go, with the Option<Method> parameters that carried a second copy
of the method.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant