Found while fixing #10453 (PR #10621), confirmed present on both the baseline and the fix, so it is a
separate defect rather than a regression.
const { AsyncResource } = require("node:async_hooks");
class NoCtor extends AsyncResource {}
new NoCtor("MyResource"); // throws: "type" argument must be of type string
A derived class with no explicit constructor gets an implicit one that should forward its arguments to
super(...). Against a native base it does not — the native super() sees no arguments, so AsyncResource's
required type string is missing and it throws.
Node runs this fine. The explicit form works today:
class WithCtor extends AsyncResource {
constructor(type) { super(type); } // works
}
This is likely not AsyncResource-specific — any native base with required constructor arguments should show it.
Worth checking Error subclasses, EventEmitter, and the stream classes for the same shape.
Related: CLAUDE.md's "Native base-class subclassing" known-weak area notes that a native base's surface is
installed at super() time, and that keying behaviour on the literal extends name loses it for fieldless
classes — a fieldless, constructor-less subclass is exactly that shape.
Found while fixing #10453 (PR #10621), confirmed present on both the baseline and the fix, so it is a
separate defect rather than a regression.
A derived class with no explicit constructor gets an implicit one that should forward its arguments to
super(...). Against a native base it does not — the nativesuper()sees no arguments, soAsyncResource'srequired
typestring is missing and it throws.Node runs this fine. The explicit form works today:
This is likely not AsyncResource-specific — any native base with required constructor arguments should show it.
Worth checking
Errorsubclasses,EventEmitter, and the stream classes for the same shape.Related: CLAUDE.md's "Native base-class subclassing" known-weak area notes that a native base's surface is
installed at
super()time, and that keying behaviour on the literalextendsname loses it for fieldlessclasses — a fieldless, constructor-less subclass is exactly that shape.