Skip to content

fix: ignore status message for HTTP/2 - #53

Merged
wesleytodd merged 6 commits into
pillarjs:2.xfrom
alexander-akait:fix-HTTP2
Aug 31, 2024
Merged

fix: ignore status message for HTTP/2#53
wesleytodd merged 6 commits into
pillarjs:2.xfrom
alexander-akait:fix-HTTP2

Conversation

@alexander-akait

@alexander-akaitalexander-akait commented Aug 19, 2024

Copy link
Copy Markdown
Contributor

fixes#45
fixes#34

/cc @wesleytodd

Comment threadtest/test.js Outdated
const servers = [
['http', createHTTPServer],
['http2', createHTTP2Server]
]

Copy link
Copy Markdown
ContributorAuthor

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

@alexander-akaitalexander-akaitAug 19, 2024

Copy link
Copy Markdown
ContributorAuthor

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)

Comment threadtest/test.js Outdated
@alexander-akait

Copy link
Copy Markdown
ContributorAuthor

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

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

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

@wesleytodd Done, diff looks better

Comment threadtest/support/utils.js Outdated
}

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

Copy link
Copy Markdown
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.

Comment threadtest/support/utils.js
}

function createServer (err, opts) {
function createHTTPServer (err, opts) {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Just rename

Comment threadtest/support/utils.js
}
}

function rawrequestHTTP2 (server) {

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtest/test.js
var nodeVersion = process.versions.node.split('.').map(Number)

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

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtest/test.js
}

return req
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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.

Comment threadtest/test.js
// http2 does not support status message
var describeStatusMessage = !/statusMessage/.test(http.IncomingMessage.toString()) || type === 'http2'
? describe.skip
: describe

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtest/test.js
})

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

Copy link
Copy Markdown
ContributorAuthor

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

Comment threadtest/test.js
})
})
})
}

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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

@wesleytodd

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

@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
Copy Markdown
ContributorAuthor

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

@wesleytodd

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

@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

@wesleytoddwesleytodd left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

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

@wesleytodd

Copy link
Copy Markdown
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.xAugust 31, 2024 18:38
@wesleytodd

Copy link
Copy Markdown
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.xAug 31, 2024
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

alexander-akait commented Sep 3, 2024

Copy link
Copy Markdown
ContributorAuthor

@alexander-akait

alexander-akait commented Sep 3, 2024

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
@wesleytoddwesleytodd mentioned this pull request Sep 3, 2024
wesleytodd pushed a commit that referenced this pull request Sep 3, 2024
@wesleytodd

Copy link
Copy Markdown
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 freeto 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

@alexander-akait@wesleytodd