You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implicit derived constructor does not forward its arguments to a native base's super(): class X extends AsyncResource {} throws on new X("type") #10623
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");classNoCtorextendsAsyncResource{}newNoCtor("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:
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.
Activity