Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12.x] http: runtime deprecate legacy HTTP parser #37603

Closed

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-bot nodejs-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 */
 }

@BethGriggs BethGriggs force-pushed the dep-warn-http-parser branch from 8828d65 to 50b3ce8 Compare March 5, 2021 11:59
@BethGriggs
Copy link
Member Author

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

@BethGriggs BethGriggs requested a review from mcollina March 5, 2021 11:59
@nodejs-github-bot
Copy link
Collaborator

doc/api/deprecations.md Outdated Show resolved Hide resolved
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.
@BethGriggs BethGriggs force-pushed the dep-warn-http-parser branch from 50b3ce8 to b2ee22f Compare March 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

@mcollina mcollina 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

mcollina commented Mar 5, 2021

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

Also, cc @nodejs/http

@jasnell
Copy link
Member

jasnell commented Mar 5, 2021

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.

@jasnell jasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 5, 2021
@richardlau richardlau added the notable-change PRs with changes that should be highlighted in changelogs. label Mar 5, 2021
@PoojaDurgad PoojaDurgad added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 8, 2021
@BethGriggs BethGriggs requested a review from richardlau March 8, 2021 11:01
@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 <rlau@redhat.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
@BethGriggs
Copy link
Member Author

Landed in a0b6104 (v12.x-staging)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs 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