-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: drop mutation of IncomingMessage owned fields, write only to new, augmented fields #4854
Comments
Hello, and sorry you are having trouble. This has been discussed prior and it is a very core feature of express and won't be changing as it is a critical feature for how middleware works. If you are trying to solve a specific problem, we are happy to help. I suggest perhaps opening a new issue describing the exact issue you are trying to solve so we can assist and perhaps help guide on if there is a feature or bug in express from there. Asking to remove a core feature thay would break the entire ecosystem is unfortunately not the appropriate starting place for such a conversation. |
I'll also add that the argument to "do not mutate properties that are part of http.IncomingMessage" are likely mute, as this is a hugely breaking change to middlewares out there that will likely need a phased migration, and Express itself will by that time not even be using http.IncomingMesage in order to support http/2, meaning req.url would acrually belong to express proper anyway, and not http.IncomingMesaage :) |
I am. I'd be happy to add greater details as requested. Please kindly ack that I did describe the problem in the
Respectfully, why not? I described a problem, then provided ideas & possible fixes to the problem. Your replies do not address the merits of the issue, which is fine. You owe me nothing (a random dude on the internet). I get that. But as a daily participant across OSS projects, GitHub issues are precisely the place for such conversation, in my experience.
I understand migrations can be tedious. Nonetheless, SemVer, versioning at large, hedge this. I read this remark as "we can't do breaking changes", and wasn't clear if that's what you really meant, or ...something else perhaps.
I'll trust your judgement here, but perhaps you'd be willing to help me understand further? Using the below as context, const http2 = require("http2");
const fs = require("fs");
const server = http2.createSecureServer({ /* snip */ });
server.on("request", (req) => {
req.url; // Http2ServerRequest::url
}); I'd assume that a |
Hi @cdaringe I took a look at your referenced issue, and it seems to me that the issue you are running in to is working against the Express mounting API (
That is correct, or perhaps as If you really want to focus on breaking the existing |
Hey Doug, great points. I was maintaining existing functionality, but in retro I think the existing functionality is exactly as you describe--counter to express' design, when it doesn't need to be. Will take it up off yonder |
Problem
express
mutatesreq.url
, and saves the un-mutated version ontooriginalUrl
, making URL driven generic middleware hard to design.Ref: chimurai/http-proxy-middleware#723
Apologies if this topic has already been discussed, I did execute a cursory search and didn't see it, but I miss things time to time.
Context
http.IncomingMessage
is thehttp
module's owned memory, and thus could be considered memory not open for writing. The writing to this memory prevents me from fixing problematic typescript issues inhttp-proxy-middleware
. To makehttp-proxy-middleware
generic is to decouple it from all frameworks that it supports--express, connect, raw http, koa, fastify, ...the works!However, because express mutates req.url, I cannot trust
http.IncomingMessage::url
, and either have to:app.use(prefix, ...)
, then additionally track that prefix internally to the HPM lib, orexpress
conditionals within HPM that sniff specifically for indicators of this framework, and use alternate logic.Solutions
don't mutate URL at all. offer functions for users to derive relative path to the base/prefix path
offer a
.relativePathname
, yieldingreq.url
-sum(...nestedPrefixes)
The text was updated successfully, but these errors were encountered: