swagger2openapi: connection issues when using http2
See original GitHub issueDetailed Description
When I try to run swagger2openapi on one of our online definitions I get the following error:
internal/http2/util.js:476
throw new ERR_HTTP2_INVALID_CONNECTION_HEADERS(key);
^
TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]: HTTP/1 Connection specific headers are forbidden: "connection"
at mapToHeaders (internal/http2/util.js:476:13)
at ClientHttp2Session.request (internal/http2/core.js:1480:25)
at HttpRequestManager.makeHttp2Request (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:413:30)
at HttpRequestManager.makeRequest (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:344:21)
at HttpRequestManager.onIdentification (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:279:24)
at HttpRequestManager.onIdentify (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:379:9)
at TLSSocket.onConnect (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:450:9)
at Object.onceWrapper (events.js:276:13)
at TLSSocket.emit (events.js:188:13)
at TLSSocket.onConnectSecure (_tls_wrap.js:1167:10)
I’ve traced it down to a difference between node-fetch-h2 and http2-client.
http2-client removes the connection header while creating a HTTP2 request. However, node-fetch-h2 adds a Connection header, note the capital C. As a result the HTTP2 request is made with a Connection header which is invalid.
The reason node-fetch-h2 adds a Connection header is due to two reasons:
- There is no connection header already
- No agent is defined on the request.
If s2o is used by oas-resolver it does define an agent and therefore doesn’t throw this issue. Swagger2openapi doesn’t do that by default.
So, either this should be fixed by one of the two dependencies or swagger2open should by default use an agent. The latter option feels valid, but curious to other opinions.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)

Top Related StackOverflow Question
Well, even with a light mocking server you can test a connection cycle. Any regression on header/connection level + response headers will be found.
Successfully published: