You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Honestly we might already, but opening this issue to track landing support and writing tests.
Node 21 added support for a new method! QUERY which is awesome, looks to have landed here nodejs/node#51719 in 21.7.2 (changelog)
@wesleytodd any idea what needs to be done to router to support QUERY? If this Issue belongs at router plz do move it!
We may actually already support this ¯_(ツ)_/¯ and it's just that a test is failing.
Im unable to get it to work in Node 21.7.3 currently, and left a comment in the node tracking issue for support nodejs/node#51562
Edit: this will light up once it fully lights up in Node, see the Node repro at the bottom
Here's my test harness rn, I don't think we support this automatically
✨✨✨
constexpress=require('express');constapp=express();constrouter=express.Router();app.use(express.json());// Test using app.query (if this is valid)try{app.query('/test-app-query',(req,res)=>{console.log({body: req.body});res.status(200).json({data: req.body});});console.log("app.query() tested and set up.");}catch(error){console.error("app.query() failed:",error);}// Test using router.query (if this is valid)try{router.query('/test-router-query',(req,res)=>{console.log({body: req.body});res.status(200).json({data: req.body});});app.use(router);console.log("router.query() tested and set up.");}catch(error){console.error("router.query() failed:",error);}// Fallback general middleware to check if QUERY method is getting throughapp.use('/test',(req,res,next)=>{if(req.method==='QUERY'){console.log('Received QUERY method via general handler');res.status(200).json({received: req.body});}else{next();}});// General error handlerapp.use((err,req,res,next)=>{console.error('Error Handler:',{ err });res.status(500).send('Server Error');});app.listen(3000,()=>{console.log("Server listening on port 3000");});
Maybe node really doesn't support this yet? Check this out:
consthttp=require('http');// Do we know about query?console.log(http.METHODS.includes('QUERY'))// true// Create an HTTP serverconstserver=http.createServer((req,res)=>{// Log the method to the console for verificationconsole.log('Received method:',req.method);// Check if the method is QUERYif(req.method==='QUERY'){res.writeHead(200,{'Content-Type': 'text/plain'});res.end('Received a QUERY method request');}else{// Respond with Method Not Allowed if the method is not QUERYres.writeHead(405,{'Content-Type': 'text/plain'});res.end('Method Not Allowed');}});// Listen on port 3000server.listen(3000,()=>{console.log('Server listening on port 3000');});
I may be wrong but I do think this is supported by express? I do remember that it worked with a manually build version of Node.js but not with the latest release @wesleytodd
Yeah that is quite possible. I thought the version with this fixed was supposed to go out with the security patch but maybe I misunderstood and it was set to land later? Based on this yes I am thinking that is the case: nodejs/node#51562 (comment)
Unfortunately I think it is still unstable in our supported node.js versions, so adding it to the types might lead folks to believe they can use it when they cannot. I don't know of a way to have the types be different depending on the Node.js version, but if there is one that I am unaware of, 22 and up have stable support for QUERY.
Activity
jonchurch commentedon Apr 20, 2024
Edit: this will light up once it fully lights up in Node, see the Node repro at the bottom
Here's my test harness rn, I don't think we support this automatically
✨✨✨
These are the curl requests Im using:
They each give me a response of:
CURL shouldn't matter here, but just in case:
Maybe node really doesn't support this yet? Check this out:
sheplu commentedon Apr 21, 2024
I may be wrong but I do think this is supported by express? I do remember that it worked with a manually build version of Node.js but not with the latest release @wesleytodd
wesleytodd commentedon Apr 22, 2024
Yeah that is quite possible. I thought the version with this fixed was supposed to go out with the security patch but maybe I misunderstood and it was set to land later? Based on this yes I am thinking that is the case: nodejs/node#51562 (comment)
skip query method test
skip query method test
skip query method test
skip query method test
Expressing `Method` via `IRouter` (#1735)
Expressing `Method` via `IRouter` (#1735)
Expressing `Method` via `IRouter` (#1735)
Issue expressjs#5615 using the express instead of http method
jonchurch commentedon Jun 5, 2024
Looks like this is now passing in Node v22.2.0, which includes this commit nodejs/node@65c8380
I don't think support will come to node 21, as the change was considered semver major by Node.
kapouer commentedon May 20, 2025
It seems that node 20.19.2 has the same issue.
wesleytodd commentedon May 20, 2025
A fix should be landed in both v4 and v5:
#6513
#6512
CxRes commentedon May 22, 2025
Please update the documentation to reflect this. See expressjs/expressjs.com#1912
RobinTail commentedon Jun 5, 2025
@wesleytodd , should we declare the
querymethod support in@types/express?wesleytodd commentedon Jun 5, 2025
Unfortunately I think it is still unstable in our supported node.js versions, so adding it to the types might lead folks to believe they can use it when they cannot. I don't know of a way to have the types be different depending on the Node.js version, but if there is one that I am unaware of, 22 and up have stable support for
QUERY.