You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add HTTP/2 support with session management and reusable connections
Implement Http2Sessions class for session pooling and timeout handling
Add httpVersion and http2Options configuration parameters
Refactor abort handling and improve error management in request lifecycle
Extract server test utilities to shared helpers module
Add comprehensive HTTP/2 test suite with various response types and scenarios
Diagram Walkthrough
flowchart LR
A["HTTP Adapter"] -->|"httpVersion=2"| B["HTTP/2 Transport"]
B -->|"getSession"| C["Http2Sessions Manager"]
C -->|"connect"| D["HTTP/2 Session Pool"]
D -->|"reuse/timeout"| E["Session Lifecycle"]
A -->|"httpVersion=1"| F["HTTP/1.x Transport"]
G["Config: httpVersion, http2Options"] -->|"merge"| A
Loading
File Walkthrough
Relevant files
Enhancement
http.js
Implement HTTP/2 support with session management
lib/adapters/http.js
Import http2 module constants and implement Http2Sessions class for session pooling with timeout management
Add http2Transport object implementing HTTP/2 request handling with header mapping
Add httpVersion and http2Options configuration parameters with validation
Refactor abort handling to use abortEmitter instead of generic emitter
Replace direct reject() calls with abort() function for consistent error handling
Update response stream handling to properly manage stream lifecycle
Change request data writing to use req.write() instead of req.end(data)
Use utils.toFiniteNumber() for content-length parsing
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful degradation
Status: 🏷️ HTTP2 session cleanup bug: The session.once('close', ...) handler dereferences authoritySessions (via entries = authoritySessions) which can be undefined for a newly-created authority, causing a runtime error during session close and preventing graceful cleanup.
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive information like PII, PHI, or cardholder data.
Status: 🏷️ Unstructured sensitive logging: The new console.warn('emit error', err) introduces unstructured logging and may log sensitive request/context data contained in err to application logs.
Objective: To prevent the leakage of sensitive system information through error messages while providing sufficient detail for internal debugging.
Status: 🏷️ Console error exposure: The new console.warn('emit error', err) may surface internal error details (potentially including stack traces) to end-users depending on how consumers handle stdout/stderr.
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent vulnerabilities
Status: 🏷️ Unvalidated http2Options passthrough: http2Options is passed through to http2.connect() without validation/sanitization, which may allow insecure TLS/session settings unless constrained elsewhere in the codebase.
In http2Transport, add 'error' event listeners to both the HTTP/2 session and the stream to ensure errors are propagated correctly through the adapter's error handling.
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 8
__
Why: This suggestion addresses a critical error handling gap by ensuring that errors from the underlying HTTP/2 session and stream are properly propagated, preventing unhandled exceptions.
Medium
Avoid mutating native stream object
Avoid mutating the native Http2Stream object in http2Transport. Instead, create a new response object that inherits from the stream to attach properties like headers and statusCode.
Why: The suggestion correctly points out that mutating a native Node.js Http2Stream object is poor practice and proposes a safer alternative using Object.create() to avoid direct mutation while preserving the prototype chain.
Low
Possible issue
Normalize and simplify session pooling
Refactor the Http2Sessions class to simplify session pooling. Normalize the session array on initialization and reference the live pool in the 'close' handler for more robust cleanup.
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 5
__
Why: The suggestion offers a reasonable refactoring of the Http2Sessions class to simplify session cleanup logic, making it more robust and easier to read, although the current implementation is not incorrect.
Low
More
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
PR_021
PR Type
Enhancement
Description
Add HTTP/2 support with session management and reusable connections
Implement
Http2Sessionsclass for session pooling and timeout handlingAdd
httpVersionandhttp2Optionsconfiguration parametersRefactor abort handling and improve error management in request lifecycle
Extract server test utilities to shared helpers module
Add comprehensive HTTP/2 test suite with various response types and scenarios
Diagram Walkthrough
File Walkthrough
http.js
Implement HTTP/2 support with session managementlib/adapters/http.js
http2module constants and implementHttp2Sessionsclass forsession pooling with timeout management
http2Transportobject implementing HTTP/2 request handling withheader mapping
httpVersionandhttp2Optionsconfiguration parameters withvalidation
abortEmitterinstead of genericemitterreject()calls withabort()function for consistenterror handling
req.write()instead ofreq.end(data)utils.toFiniteNumber()for content-length parsingserver.js
Add HTTP/2 server support with self-signed certificatestest/helpers/server.js
http2andselfsignedmodule imports for HTTPS supportuseHTTP2,key, andcertparameters to server configurationuseHTTP2flag is enabledcloseAllSessions()method for HTTP/2servers
keepAliveTimeoutonly for HTTP/1.x servershttp.js
Add HTTP/2 tests and refactor test utilitiestest/unit/adapters/http.js
startHTTPServer,stopHTTPServer,handleFormData, andgenerateReadableto shared helpersserver2variable and HTTP/2 specific port constantstoleranceRange()calculation logic for rate limit testingFormData, response types, timeouts, cancellation, and session
management
assert.rejects()patternindex.d.ts
Add HTTP/2 type definitionsindex.d.ts
httpVersionoption typed as1 | 2for protocol version selectionhttp2Optionsconfiguration object with optionalsessionTimeoutparameter
index.d.cts
Add HTTP/2 type definitions for CommonJSindex.d.cts
httpVersionoption typed as1 | 2for protocol version selectionhttp2Optionsconfiguration object with optionalsessionTimeoutparameter
README.md
Document HTTP/2 feature and usageREADME.md
httpVersionandhttp2OptionsconfigurationsessionTimeoutparameter and session reuse behaviorpackage.json
Add selfsigned certificate dependencypackage.json
selfsigneddependency version^3.0.1for generating self-signedcertificates in tests