Repository navigation
Convert console.count() and console.time() labels to strings - #8843
Conversation
There was a problem hiding this comment.
Superseded by the review of
2944ba2a.
This review, of 5a708a80
✅ Approved — I found no issues: the label conversion is correct, sits behind a new compatibility flag, survives the startup snapshot, and is tested with the flag on and off.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
The wrapper leaves conversion errors pending and returns, forwards the other arguments unchanged, and keeps the builtin as the function's data. It is installed after the existing guard in setupContext and registered as an external reference. The flag ordinal and names match the tests and the WPT config.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The flag's doc comment describes the current behaviour with and without the flag.
Reviewed commit: 5a708a80
5a708a8 to
2944ba2
Compare
There was a problem hiding this comment.
Superseded by the review of
169acfae.
This review, of 2944ba2a
✅ Approved — No issues found. The label conversion is correct, sits behind a new compatibility flag, survives the startup snapshot and is tested with the flag on and off; the only change since the last review is a comment fix.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns. When ToString throws, the wrapper makes no further V8 calls that take a context, so the exception keeps propagating.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
The ConsoleMethod comment now matches the code.
- The label wrapper leaves conversion errors pending and returns.
- It forwards
thisand the other arguments unchanged. - It keeps the builtin as the function's data.
- It is registered as an external reference and installed only after the existing guard.
The flag names match the tests and the WPT config.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The flag's doc comment describes the current behaviour with and without the flag.
Reviewed commit: 2944ba2a
2944ba2 to
169acfa
Compare
There was a problem hiding this comment.
Superseded by the review of
24cb3660.
This review, of 169acfae
✅ Approved — No issues found. The label conversion sits behind a new compatibility flag, survives the startup snapshot and is tested with the flag on and off. The only change since the last review is a doc comment fix.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns. When ToString throws, the wrapper makes no further V8 calls that take a context, so the exception keeps propagating.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
No issues found. Checked at this commit:
- Compat flag:
consoleLabelConversion @211takes the next free ordinal. - Wrapper:
consoleLabelDecoratorconverts the label withToString. If that throws, it returns right away without making further V8 calls, so the exception keeps propagating. It forwardsthisand the other arguments unchanged and keeps the builtin as its function data. - Snapshot and install order: the wrapper is registered as an external reference, so it survives the startup snapshot, and it is installed only after the existing guard in
setupContext. - Tests: they cover all five methods with the flag on and off. The WPT config turns the flag on and drops the expected failures.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The flag's doc comment describes how the methods behave with and without the flag.
Reviewed commit: 169acfae
|
I'd be shocked if this actually broke anything in production. Probably ok to change without the compat flag, to be honest, but don't feel strongly either way. |
console.count(), countReset(), time(), timeLog() and timeEnd() are V8's builtins. They pass the label to the inspector's console delegate and never look at it otherwise, so without an inspector an object label's toString() is never called, and a label whose conversion throws, such as a Symbol, is silently accepted. With an inspector the delegate converts the label but drops the error. The Console spec converts the label to a string first and rethrows. In this patch setupContext wraps those five methods. The wrapper converts a label that isn't undefined with ToString(), rethrowing what it throws, then calls the builtin with the string and the other arguments unchanged. There is no compat flag. What a Worker can see: toString() is now called on object labels, and console.count(Symbol()) or a label whose toString() throws now throws instead of doing nothing. Browsers and Node.js already behave this way, so portable code expects it.
console-label-conversion-test runs count, countReset, time, timeLog and timeEnd with an object label, a throwing toString(), a Symbol, no label and extra arguments. It fails without the previous commit. The 10 expected failures in WPT's console-label-conversion.any.js are removed.
169acfa to
24cb366
Compare
There was a problem hiding this comment.
✅ Approved — No issues found. The wrapper rethrows conversion errors correctly, survives the startup snapshot and is tested on all five methods, and the commit message records the decision to ship without a compat flag.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns. When ToString throws, the wrapper makes no further V8 calls that take a context.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
Checked at this commit:
- Wrapper: If
ToStringthrows,consoleLabelDecoratorreturns right away without making further V8 calls, so the exception keeps propagating. A missing orundefinedlabel reaches the builtin unchanged, as dothisand the other arguments. - Snapshot and install order:
&consoleLabelDecoratoris registered as an external reference. The wrapper is installed after the existing early-return guard insetupContext, andSetNamekeeps each method'snameintact. - Compatibility: The change has no compat flag. The commit message of 8c0d8ab explicitly accepts that risk and describes what Worker code can observe, which is what the backward-compatibility rules ask for.
- Tests: They cover all five methods with an object label, a throwing
toString(), a Symbol, no label and extra arguments. The WPT expected failures forconsole-label-conversion.any.jsare removed.
⚡ Performance: ✅ LGTM
Each call to one of the five label methods costs one ToString and one extra call. These methods are not hot paths, and the wrappers are installed once per context.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: 24cb3660
|
Removed the compat flag. |
console.count(),countReset(),time(),timeLog()andtimeEnd()are V8's builtins. They hand the label to the inspector's console delegate and never look at it otherwise. Without an inspector, an object label'stoString()is never called, and a label whose conversion throws, such as a Symbol, is silently accepted. With an inspector, the delegate converts the label but drops the error. The Console spec converts the label to a string first and rethrows, which accounts for the 10 expected failures in WPT'sconsole-label-conversion.any.js.In this patch
setupContextwraps those five methods. The wrapper converts any label other thanundefinedwithToString(), rethrows what that throws, and then calls the builtin with the string and the other arguments unchanged. The builtin is kept as the wrapper's function data, and the wrapper is registered as an external reference so it survives the startup snapshot.There is no compat flag. What a Worker can see:
toString()is now called on object labels, andconsole.count(Symbol()), or any label whosetoString()throws, now throws instead of doing nothing. Browsers and Node.js already behave this way, so portable code expects it.console-label-conversion-testcovers each of the five methods with an object label, a throwingtoString(), a Symbol, no label and extra arguments. It fails without the fix, and so does//src/wpt:console@, which has no expected failures left for this file.