Repository navigation
Remove jsg::Name - #8212
Remove jsg::Name#8212
Conversation
jsg::Name had two consumers, neither of which needed it:
- UtilModule::getResourceTypeInspect() now returns a jsg::JsSymbol from
js.symbolInternal(), which, like the removed Lock::newApiSymbol(), is
v8::Symbol::ForApi(). JS sees the same Symbol.forApi("kResourceTypeInspect")
symbol as before.
- DiagnosticsChannelModule::publishToTracer() built a jsg::Name only to call
toString() on it. It now computes the string directly with the same
expressions: strings pass through unchanged and symbols become
"Symbol(<description>)", so the tracer gets the same channel-name string.
Lock::newSymbol(), newSharedSymbol() and newApiSymbol() returned Name and
duplicated Lock::symbol(), symbolShared() and symbolInternal(), so they are
removed too. NameWrapper, its TypeWrapper registration, the RTTI mapping, its
value-test cases and its documentation go with it. The JSG_NAME value stays in
the rtti.capnp JsgImplType enum, because removing an enumerant would renumber
the rest.
No behaviour changes; the generated type snapshot is unchanged.
There was a problem hiding this comment.
Superseded by the review of
2ba1df92.
This review, of 33ab9d42
✅ Approved — A clean removal: both callers keep the same behaviour, and none of the changed lines has a problem.
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
Both replacement call sites keep the same behaviour, and no references to the removed types are left under src/.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The Name docs were removed from docs/jsg.md and src/workerd/jsg/README.md, as they should be.
Reviewed commit: 33ab9d42
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8212 +/- ##
=======================================
Coverage 68.79% 68.79%
=======================================
Files 743 743
Lines 194673 194576 -97
Branches 30171 30151 -20
=======================================
- Hits 133925 133863 -62
+ Misses 43043 43018 -25
+ Partials 17705 17695 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
✅ Approved — A clean removal: both callers keep the same behaviour, and none of the changed lines has a problem.
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
Both replacement call sites keep the same behaviour, and no references to the removed types are left under src/.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The Name docs were removed from docs/jsg.md and src/workerd/jsg/README.md, as they should be.
Reviewed commit: 2ba1df92 — same changes as 33ab9d42, so this is that commit's review (no new review was run; line numbers are as of 33ab9d42)
Remove
jsg::Namejsg::Nameheld either a string or av8::Symbol. It had two consumers in C++, and neitherneeded it. This PR moves both to existing types and deletes
Name,NameWrapper, and theLock::newSymbol(),newSharedSymbol()andnewApiSymbol()helpers.Changes
UtilModule::getResourceTypeInspect()returnsjsg::JsSymbolfromjs.symbolInternal()inplace of
jsg::Namefromjs.newApiSymbol().DiagnosticsChannelModule::publishToTracer()builds the channel-namekj::Stringdirectly.It no longer builds a
jsg::Nameand callstoString()on it.Name(jsg.h/jsg.c++),NameWrapper(value.h) and itsTypeWrapperregistration,the
jsg::NameRTTI mapping (rtti.h), theLock::new*Symbol()helpers, thevalue-test.c++cases, and the docs in
jsg/README.mdanddocs/jsg.md.Why this is safe
Nothing else uses it. After this change,
src/has no references tojsg::Name,NameWrapperorLock::new*Symbol(). The only callers ofnew*Symbol()outsidegetResourceTypeInspect()were invalue-test.c++. Rust JSG has its ownv8::Namemarker typeand never used the C++ class. The internal repo doesn't use
jsg::NameornewApiSymboleither.kResourceTypeInspectis the same symbol.newApiSymbol(s)wasv8::Symbol::ForApi(isolate, v8StrIntern(isolate, s)), andLock::symbolInternal(s)is the sameexpression. For a symbol,
NameWrapper::wrap()returned the handle unchanged, and so does wrappinga
JsSymbol. The property is still declared withJSG_READONLY_INSTANCE_PROPERTY, so itsattributes don't change either.
internal_inspect.ts,internal_mime.tsandmessagechannel.ts,which look the symbol up with
getApiSymbol('kResourceTypeInspect'), still get the same symbol.The tracer channel name is the same string. The new code uses the expressions from
Name::toString():Name(nameValue.toString(js))stored the string andtoString()returned a copy of it. Now the code uses
nameValue.toString(js)directly.kj::str("Symbol(", symbol->Description(isolate), ")").A symbol without a description is formatted the same way as before, because the same
Description()handle goes through the samekj::strstringification. Both the normal path andthe fallback path for unserializable messages send this string.
TypeScript output doesn't change. No public API took or returned
jsg::Name;UtilModuleis internal (node-internal:util).just generate-typesleavestypes/generated-snapshot/unchanged.The RTTI schema is unchanged.
JSG_NAMEstays in theJsgImplTypeenum inrtti.capnp,because removing it would shift the numbers of the values after it. The
types/generator keepsits
JSG_NAMEcase: itsswitchends with an exhaustivesatisfies nevercheck, so the casehas to stay for as long as the enum value exists. C++ no longer produces this value.