I've got a weird case where http & https works without problem. However, http2 compat does not.
In the case where I'm trying to do a PATCH, PUT or POST the request doesn't finish with http2. GET, HEAD and other "safe" methods work without problem.
Given that http2 compat should be mostly an in place replacement for http I believe this is a bug somewhere?
I'm basically using http2-proxy something like:
const http2 = require('http2')
const proxy = require('http2-proxy')
const http = require('http')
const fs = require('fs')
const proxyServer = http2
.createSecureServer({
cert: fs.readFileSync('./server.crt'),
key: fs.readFileSync('./server.key'),
allowHTTP1: true
})
.on('request', (req, res) => {
proxy.web(req, res, {
hostname: 'localhost',
port: 7000
}, err => {
if (err) {
console.error('proxy error', err)
}
})
})
.listen(6000)
const server = http
.createServer()
.on('request', (req, res) => {
req
.pipe(fs.createWriteStream(Math.random().toString()))
.on('finish', () => {
res.statusCode = 200
res.end()
})
})
.listen(7000)
Can't create a full repo since I don't know how to do http2 requests in node.
I've tried with master.
Just an FYI, but you can't do allowHTTP1 with createServer, only createSecureServer. Not sure if that's the culprit as I'm having trouble following exactly what's going wrong. Any more debugging info or a full-source that I can run to reproduce it would be helpful. Thanks!
Also browsers won't connect via http2 to a non-secure server.
@apapirovski: It's the same with createSecureServer.
A full source is going to be difficult since there are quite a lot of components involved to get it fully working.
Have to think about how/if I can create a repo case you can run.
What kind of debugging info would be useful?
Do you have an example of how to create a http2 file upload using a client in node?
Yeah, for sure. This test has a fully working example: https://github.com/nodejs/node/blob/master/test/parallel/test-http2-client-upload.js
@apapirovski: The minimal case seems to work. So basically:
Not sure where to go from here...
Can you tell me a bit more about what's happening in the full case? How exactly is the comparison for http vs http2 being done 鈥斅燼re you just swapping http2.createSecureServer for the equivalent http/https version or something more? How far does it get in the http2 version 鈥斅燿oes the proxied to server receive the data at all?
Would love to help (since it sounds like there might be a legitimate issue) but it's hard without insight into what your code is doing, especially since the reduced test case works for you.
I'm making a simple proxy that forwards http2 requests from Chrome to our backend storage server:
Currently, I simply switch from http2 to http like this:
// Doesn't work
// const httpsServer = http2
// .createSecureServer({
// cert: readFileSync('./server.crt'),
// key: readFileSync('./server.key'),
// allowHTTP1: true
// })
const httpsServer = https
.createServer({
cert: readFileSync('./server.crt'),
key: readFileSync('./server.key')
})
When I try to upload from Chrome the requests are stuck on "pending":



Using nginx instead as http2->http1 proxy works. So I don't think it's a problem with the storage server.
We're trying to replace nginx with a minimal node alternative.
I think I'm able to replicate the issue. Looking into it.
Issue is definitely in http2 and I can reproduce it with a minimal test case involving pipe. Trying to find the root cause and will submit a PR when done. Thanks for the report @ronag.
this same problem with me
@ronag I have a proposed patch in https://github.com/nodejs/node/pull/15503. If you wouldn't mind testing it against your code, that would be absolutely amazing. I think my test case matches but it's possible there's also another issue at play.
@apapirovski: Yep, that fixes it!