Skip to content

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

@bkaradzic-microsoft

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions