Uh oh!
There was an error while loading. Please reload this page.
esm: avoid try/catch when validating urls - #47541
Conversation
nodejs-github-bot
commented
Apr 13, 2023
Review requested:
|
anonrig
commented
Apr 13, 2023
@aduh95 I like where this is going, but I couldn't visualize it. Can you elaborate on how we can import it primordial-style? We can always do |
aduh95
commented
Apr 13, 2023
Yes, I mean something that's available only internally and cannot be mutated at runtime. |
5375959 to
3a57762Comparenodejs-github-bot
commented
Apr 13, 2023
ljharb
commented
Apr 13, 2023
This is way better/cleaner :-) but does it prevent backporting this commit, since older release lines may not have URL.canParse? |
anonrig
commented
Apr 13, 2023
It might make it harder, due to conflicts, but I don't think it will block backporting any future changes to ESM. |
ljharb
commented
Apr 13, 2023
oh sure, i just meant, should this PR have any "do not backport" labels, or link to the canParse PR as a prereq? |
anonrig
commented
Apr 13, 2023
I'm not quite sure. @nodejs/releasers what do you recommend? |
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Sweet, thanks! I was just suggesting this change last night in Slack 😁
aduh95
commented
Apr 13, 2023
|
mscdex
commented
Apr 13, 2023
I'm confused by this. The C++ API still says this: Lines 116 to 117 in 4afb25c Or did you actually mean this PR does not improve performance until the TODO is resolved? |
anonrig
commented
Apr 13, 2023
I was giving some context to this particular change. It is definitely faster than the current implementation. Additionally, @KhafraDev just opened a pull request for adding v8 fast API to |
ljharb
commented
Apr 13, 2023
@aduh95 perfect, thanks for clarifying and linking :-) |
3a57762 to
05742e9Comparenodejs-github-bot
commented
Apr 14, 2023
nodejs-github-bot
commented
Apr 14, 2023
anonrig
commented
Apr 14, 2023
Would someone re-review this pull request? It's required due to force-push. |
| } = require('internal/errors').codes; | ||
| const { exitCodes: { kUnfinishedTopLevelAwait } } = internalBinding('errors'); | ||
| const { URL } = require('internal/url'); | ||
| const { canParse: urlCanParse } = internalBinding('url'); |
There was a problem hiding this comment.
nit: this sounds a little Yoda-esque
| const{canParse: urlCanParse}=internalBinding('url'); | |
| const{canParse: canParseURL}=internalBinding('url'); |
There was a problem hiding this comment.
Not sure this is better, isURLString might be more suited. URLCanParse has the upside of being consistent with how primordials are named, which is nice imho
There was a problem hiding this comment.
I want to change this to URLCanParse too but I'm too demotivated by having to run Node.js CI multiple times because of the flaky tests.
nodejs-github-bot
commented
Apr 15, 2023
Landed in 17570c0 |
PR-URL: #47541 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
PR-URL: nodejs#47541 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
PR-URL: nodejs/node#47541 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
PR-URL: nodejs/node#47541 Backport-PR-URL: nodejs/node#50669 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Due to
URL.canParse, we can avoid try/catch block and have faster validation. The previous implementation was not performant due to:href,originetc. for validating if a URL is valid or not.URL.canParsecan be written with V8 Fast API - enabling more performance out of this pull request.URL.canParsedoes not return anything except a boolean.cc @nodejs/url