Skip to content
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

fix: ignore status message for HTTP/2 #53

Merged
merged 6 commits into from
Aug 31, 2024

Conversation

alexander-akait
Copy link
Contributor

@alexander-akait alexander-akait commented Aug 19, 2024

fixes #45
fixes #34

/cc @wesleytodd

test/test.js Outdated
const servers = [
['http', createHTTPServer],
['http2', createHTTP2Server]
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make full testing

Copy link
Contributor Author

@alexander-akait alexander-akait Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No one test was deleted, just remove describe('finalhandler(req, res)', () => {}) wrapper to avoid extra nesting (reading purposes)

test/test.js Outdated Show resolved Hide resolved
@alexander-akait
Copy link
Contributor Author

Looks like we need ignore one case - https://github.com/pillarjs/finalhandler/actions/runs/10457238346/job/28956872842?pr=53, WIP 😄

test/test.js Outdated
['http2', createHTTP2Server]
]

for (var i = 0; i < servers.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it matters, but one thing we could do to reduce the change set here would be to do the loop outside of the old code to not make it indent more. Something like this:

var topDescribe = function(createServer) { return function () { /* ... */} }
for (var i = 0; i < servers.length; i++) {
  describe(name, topDescribe(createServer));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove the indent you would need that inner function to be named, but just wanted to do some example code to show how to write this without the whole file being marked as changed.

@alexander-akait
Copy link
Contributor Author

@wesleytodd Done, diff looks better

})
}

function createHTTP2Server (err, opts) {
return http.createServer(function (req, res) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something here? Is this supposed to be using http2? Sorry if I am being silly here, barely started my morning coffee.

@@ -26,7 +37,7 @@ function createError (message, props) {
return err
}

function createServer (err, opts) {
function createHTTPServer (err, opts) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just rename

@@ -107,6 +131,72 @@ function rawrequest (server) {
}
}

function rawrequestHTTP2 (server) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing raw HTTP2 request

var nodeVersion = process.versions.node.split('.').map(Number)

// `superagent` only supports `http2` since Node.js@10
if (http2 && nodeVersion[0] >= 10) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superagent (under the hood of supertest) supports http2 since Node.js@10, for old versions you will get:

Error: superagent: this version of Node.js does not support http2

}

return req
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we could have wrapper make the request call? Then if we just renamed it to request all the below code would remain unchanged. I am not going to consider this blocking, and I recognize you have put in a bunch of good work getting this here, so I hate asking for more for such nitpicks, but it would be nice to have the diff be more clear.

// http2 does not support status message
var describeStatusMessage = !/statusMessage/.test(http.IncomingMessage.toString()) || type === 'http2'
? describe.skip
: describe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip tests for statusMessage, because it is not supported for http2

.expect(500, done)
})

it('should override with err.status', function (done) {
var server = http.createServer(function (req, res) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use createServer instead http.createServer to test using http2 too, the same for tests below

})
})
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make these test for http and http2

@alexander-akait
Copy link
Contributor Author

/cc @wesleytodd Rewrote and corrected everything, everything works locally, plus left comments about the changes

@wesleytodd
Copy link
Member

Sorry, we will be dropping these old node versions which dont support new language features. It will really help folks trying to contribute not have to deal with failures like this. Unfortunately we had a nearly 10 years of stalling out to catch up on here. Rest assured, we are working toward fixing this situation.

@alexander-akait
Copy link
Contributor Author

@wesleytodd

Sorry, we will be dropping these old node versions which dont support new language features. It will really help folks trying to contribute not have to deal with failures like this. Unfortunately we had a nearly 10 years of stalling out to catch up on here. Rest assured, we are working toward fixing this situation.

I didn't quite understand you, we don't test only on them because it's not supported http2 on this version and that's it

@alexander-akait
Copy link
Contributor Author

@wesleytodd it should work now, it's strange that using nvm locally the tests passed, fixes syntax

@wesleytodd
Copy link
Member

I didn't quite understand you, we don't test only on them because it's not supported http2 on this version and that's it

Right, but the test failure was because you used an arrow function. So even though those tests were not meant to run in 0.8, you can't even use arrow functions anywhere in the code or it will fail. That is all I meant.

@alexander-akait
Copy link
Contributor Author

@wesleytodd

Right, but the test failure was because you used an arrow function. So even though those tests were not meant to run in 0.8, you can't even use arrow functions anywhere in the code or it will fail. That is all I meant.

Yeah, fixed, as I written above it is strange because I use nvm to test locally and all works fine, apparently nvm launches node.js with flags which enable support new features for old versions

Copy link
Member

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pillarjs/express-tc Would love it if someone else could get some eyes on this. I think it looks ready to go.

@alexander-akait
Copy link
Contributor Author

I think @pillarjs/express-tc doesn't work

@wesleytodd
Copy link
Member

It works, but apparently I never updated this membership list to the current Express TC. I will do that now, and will also post in our slack to help make sure folks see this.

@wesleytodd wesleytodd changed the base branch from master to 2.x August 31, 2024 18:38
@wesleytodd
Copy link
Member

Sorry to switch this at the lats minute, but I am going to release 2.x right now so figured it is easier to do this in one release. Since you have done the things needed to land this in the 1.x line, if you need it there let me know and I can back port it as well, but on the chance you dont need it that badly I didn't want to do the extra release if we didn't need to.

@wesleytodd wesleytodd merged commit 6dd0318 into pillarjs:2.x Aug 31, 2024
28 checks passed
wesleytodd pushed a commit that referenced this pull request Sep 2, 2024
* fix: ignore status message for HTTP/2

* test: fix

* test: fix node@9

* refactor: tests

* test: fix

* test: fix syntax
@alexander-akait alexander-akait deleted the fix-HTTP2 branch September 3, 2024 11:41
@alexander-akait
Copy link
Contributor Author

alexander-akait commented Sep 3, 2024

@alexander-akait
Copy link
Contributor Author

alexander-akait commented Sep 3, 2024

I want to avoid creation another conect compatibility framework, don't know why we need a major release, it is just a message with deprication

@wesleytodd
Copy link
Member

We needed it because the entire Express project is dropping old node versions. If we are touching libraries we are doing majors to drop support, it had nothing to do with this change. We only have a few folks who have volunteered and shown up to work on this stuff, so I was trying to be efficient with my time. I can back port it to 1.x, might just be a bit while I get setup for the day.

@alexander-akait
Copy link
Contributor Author

that would be good, we can't update it in 3rd modules, I am afraid you really will be overloaded issues from tens of thousands of developers, all I try to do is reduce your potential problems, I don't see any problem to use it for 1 version, we haven't changed anything critical, sorry, but the argument about deprecation old Node.js versions has no meaning here, it will take a long time before everything can be updated, also I don't know your roadmap and it was ready, and the current problem that I'm trying to solve is quite obvious and exists right now

wesleytodd pushed a commit that referenced this pull request Sep 3, 2024
@wesleytodd wesleytodd mentioned this pull request Sep 3, 2024
wesleytodd pushed a commit that referenced this pull request Sep 3, 2024
@wesleytodd
Copy link
Member

Yep thanks, I think with all the changes we have been pushing on these proejcts I forgot that you had said you needed it on 1.x. I should have just released it on both, my bad. Was a long weekend and I was spread way too thin.

but the argument about deprecation old Node.js versions has no meaning here

Sorry if I was not clear, but I just meant I had to push a major for entirely unreleated reasons to this PR. Originally I was not even planning on releasing a 1.x release but then the issue with the null socket came up, and in my flurry of work I forgot to include backporting this to the 1.x release first. Please understand that these packages were left dormant for like 6 years, and we are just a small group of volunteers trying to get them back to a functional state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants