Skip to content

Conversation

@BethGriggs
Copy link
Member

The legacy HTTP parser, used by default in versions of Node.js prior to
12.0.0, is deprecated. The legacy HTTP parser cannot be guaranteed to be
supported after April 2021. This commit introduces a deprecation warning
for the legacy HTTP parser.

Refs: #31441


I wasn't sure whether the warning should be emitted upon load or when --http-parser=legacy is specified as an option (similar to https://github.com/nodejs/node/blob/master/src/node_options.cc#L41). Happy to move the deprecation to there, if that is preferred.

@nodejs-github-botnodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. v12.x labels Mar 4, 2021
@richardlau
Copy link
Member

Another way would be to emit the warning from the C++ layer which would emit the deprecation even if someone did process.binding('http_parser') regardless of the setting of --http-parser.

diff --git a/src/node_http_parser_impl.h b/src/node_http_parser_impl.h index 7c39bc15c7..6aaba922b5 100644 --- a/src/node_http_parser_impl.h+++ b/src/node_http_parser_impl.h@@ -26,6 +26,9 @@ #include "node.h" #include "node_buffer.h" +#ifndef NODE_EXPERIMENTAL_HTTP+#include "node_process.h"+#endif /* NODE_EXPERIMENTAL_HTTP */ #include "util.h" #include "async_wrap-inl.h" @@ -1021,6 +1024,10 @@ void InitializeHttpParser(Local<Object> target, #ifndef NODE_EXPERIMENTAL_HTTP static uv_once_t init_once = UV_ONCE_INIT; uv_once(&init_once, InitMaxHttpHeaderSizeOnce); + ProcessEmitDeprecationWarning(+ env,+ "The legacy HTTP parser deprecated.",+ "DEP0131").IsNothing(); #endif /* NODE_EXPERIMENTAL_HTTP */ }

@BethGriggsBethGriggsforce-pushed the dep-warn-http-parser branch from 8828d65 to 50b3ce8CompareMarch 5, 2021 11:59
@BethGriggs
Copy link
MemberAuthor

@richardlau I think that approach makes sense, changed to that.

@BethGriggsBethGriggs requested a review from mcollinaMarch 5, 2021 11:59
@nodejs-github-bot
Copy link
Collaborator

The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0, is deprecated. The legacy HTTP parser cannot be guaranteed to be supported after April 2021. This commit introduces a deprecation warning for the legacy HTTP parser.
@BethGriggsBethGriggsforce-pushed the dep-warn-http-parser branch from 50b3ce8 to b2ee22fCompareMarch 5, 2021 12:25
@richardlau
Copy link
Member

We may also want to update the documentation for the --http-parser= option? https://nodejs.org/docs/latest-v12.x/api/cli.html#cli_http_parser_library

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@mcollina
Copy link
Member

I would recommend a few more reviews by the @nodejs/tsc team.

Also, cc @nodejs/http

@jasnell
Copy link
Member

Adding a runtime deprecation is typically semver-major and not something we would typically backport, especially not into an LTS line. In this case, there's likely a good reason for us to go ahead and do it given the complete switch over to llhttp. This should at least be a semver-minor.

@jasnelljasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 5, 2021
@richardlaurichardlau added the notable-change PRs with changes that should be highlighted in changelogs. label Mar 5, 2021
@PoojaDurgadPoojaDurgad added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 8, 2021
@nodejs-github-bot
Copy link
Collaborator

BethGriggs added a commit that referenced this pull request Mar 8, 2021
The legacy HTTP parser, used by default in versions of Node.js prior to 12.0.0, is deprecated. The legacy HTTP parser cannot be guaranteed to be supported after April 2021. This commit introduces a deprecation warning for the legacy HTTP parser. PR-URL: #37603 Refs: #31441 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
@BethGriggs
Copy link
MemberAuthor

Landed in a0b6104 (v12.x-staging)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.httpIssues or PRs related to the http subsystem.needs-ciPRs that need a full CI run.notable-changePRs with changes that should be highlighted in changelogs.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@BethGriggs@richardlau@nodejs-github-bot@mcollina@jasnell@benjamingr@targos@dnlup@PoojaDurgad