QuickJS Node-API conformance defects

Open
#2,128 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, javascript
Domain
backend, testing

Research direction

Start with Dependencies/JsRuntimeHost/Core/Node-API/Source/js_native_api_quickjs.cc and the exclusions in Dependencies/JsRuntimeHost/Tests/NodeApi/test_main.cpp. Run the named conformance tests under test_general/, test_constructor/, test_number/, test_conversions/, and test_new_target/ to inspect the listed QuickJS failures. Fix the affected Node-API behavior and remove each corresponding exclusion once its test passes.

Written by the indexing model from the issue text.

Description

[Filed by Copilot on behalf of @bghgary]

The Node-API conformance suite added in #2097 skips these tests on QuickJS. Their exclusions in Dependencies/JsRuntimeHost/Tests/NodeApi/test_main.cpp link here; the implementation is Dependencies/JsRuntimeHost/Core/Node-API/Source/js_native_api_quickjs.cc. Remove an exclusion when its item is fixed, so the test guards the fix.

  • There is no napi_add_finalizer or napi_adjust_external_memory, so the test_general addon cannot load and is not built. Skips test_general/.
  • napi_define_class dereferences a NULL properties array and crashes. Skips test_constructor/test.js and test_constructor/test_null.js.
  • Read-only assignment errors use different message text from V8's, which test_constructor/test.js also asserts.
  • napi_get_value_int64 casts out-of-range doubles instead of saturating. Skips test_number/test.js.
  • Number getters coerce non-numbers instead of returning napi_number_expected, and string getters accept a NULL buf and result. Skips test_conversions/test.js.
  • napi_create_function creates the function with JS_NewCFunctionData, which is not a constructor, so a class cannot extend it. Skips test_new_target/test.js.
  • napi_define_class constructors record the function itself as new.target and take the instance's prototype from it, so napi_get_new_target returns the wrong value and subclass instances lose their methods. test_new_target/test.js also needs this fixed.
Dominant language
C++
Stars
931
Forks
169
Avg merge
2d 17h
Merged PRs (30d)
66

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BabylonJS/BabylonNative

All issues in BabylonJS/BabylonNative

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.