Skip to content

Node-API-JSC: napi_typeof reports napi_object for JSObjectMakeConstructor constructors #194

Closed

Description

@bkaradzic-microsoft

Follow-up from the native fetch() polyfill review (#188).

napi_typeof in js_native_api_javascriptcore.cc decides function-ness solely via JSObjectIsFunction, which returns false for constructors created with JSObjectMakeConstructor on some JSC builds (e.g. libjavascriptcoregtk). As a result it reports napi_object where V8 returns napi_function, so Napi IsFunction() incorrectly rejects otherwise-valid constructors (e.g. the Blob polyfill).

Both the Fetch polyfill (#188) and the File polyfill currently carry an identical IsUndefined()/IsNull() workaround to detect the constructor without IsFunction().

A fix in napi_typeof (also consulting JSObjectIsConstructor in addition to JSObjectIsFunction) would let both polyfills drop the workaround rather than spreading per-polyfill copies.

Activity

  1. added this to the 10.0 milestone on Jun 30, 2026
  2. bkaradzic-microsoft commented on Aug 18, 2026

    @bkaradzic-microsoft
    MemberAuthor

    Fixed by #207 (merged 2026-07-28).

    That PR changed napi_typeof in Core/Node-API/Source/js_native_api_javascriptcore.cc to consult JSObjectIsConstructor in addition to JSObjectIsFunction, so constructors created via JSObjectMakeConstructor (i.e. node-addon-api DefineClass constructors) now report napi_function on JSC builds such as libjavascriptcoregtk, matching V8.

    With that in place the IsUndefined()/IsNull() workarounds carried by the Fetch (#188) and File polyfills were removed in the same PR.

    Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions