nodejs / nodejs/node-api-cts

Some tests assert V8's exact error message wording, so non-V8 runtimes fail on prose

Đang mở
#84 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C
Star
18
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

To see how far a non-V8 runtime gets, I ran the suite under Bun 1.3.14 (JavaScriptCore)
on Linux, with the addons rebuilt with GCC and the tests spawned the same way the node
implementor does. 43 of the 48 test files pass. Of the five failures, two are genuine
Node-API gaps in Bun (zero length external strings and Float16Array in the typed array
APIs, both since fixed on Bun's main branch). The other three fail only because the test
compares the thrown error's message text against V8's exact wording, and JavaScriptCore
words the same conditions differently. The same three files fail identically on Windows
with MSVC-built addons, which is where the quoted output below comes from.

The affected assertions:

test expects JSC actually throws
test_constructor/test.js line 15 /^TypeError: Cannot assign to read only property 'readonlyValue' of object '#<MyObject>'$/ TypeError: Attempted to assign to readonly property.
test_constructor/test.js lines 38, 42 /^TypeError: Cannot set property .* of #<.*> which has only a getter$/ TypeError: Attempted to assign to readonly property.
test_properties/test.js line 16 /^TypeError: Cannot assign to read only property '.*' of object '#<Object>'$/ TypeError: Attempted to assign to readonly property.
test_properties/test.js lines 55, 59 /^TypeError: Cannot set property .* of #<Object> which has only a getter$/ TypeError: Attempted to assign to readonly property.
test_bigint/test.js line 46 { name: 'RangeError', message: 'Maximum BigInt size exceeded' } RangeError: Out of memory

Three files, seven assertion sites, and it comes down to two JSC strings. Each run stops
at its first failing assertion, so the later sites in each file were confirmed by
evaluating the same operations directly under Bun in strict mode; JSC uses the single
Attempted to assign to readonly property. message for both the read only data property
and the getter-only accessor cases.

A representative failure from the run:

AssertionError: The input did not match the regular expression /^TypeError: Cannot assign to read only property 'readonlyValue' of object '#<MyObject>'$/. Input:

'TypeError: Attempted to assign to readonly property.'

and for the BigInt case:

Comparison {
+   message: 'Out of memory',
-   message: 'Maximum BigInt size exceeded',
    name: 'RangeError'
  }

What these assertions actually verify is real Node-API behavior: that
napi_define_properties produced a property that rejects writes with a TypeError, and
that the engine's own RangeError from an oversized BigInt propagates out of
napi_create_bigint_words as the pending exception. That part holds in Bun. The message
text on top of it is engine identity rather than conformance, and every non-V8 engine
(JSC here, Hermes and SpiderMonkey elsewhere) words it its own way, so as written a
conformant runtime scores red on strings it cannot change. The regexes came along
naturally with the ports from nodejs/node, where a single-engine assumption was fine.

A few possible directions, and I would rather follow your preference than pick one:

  1. Assert the error type and the behavior (the write throws and does not take effect,
    the BigInt call throws a RangeError) and drop the message text entirely.
  2. Keep a message assertion but loosen it to a shape every engine can meet, for example
    just /TypeError/, or name plus a much weaker pattern.
  3. Keep exact messages but make the expected strings per implementor, in the same spirit
    as features.js already being per implementor.

Happy to send a PR for whichever direction you want, or none if you would rather handle
it differently.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các vị trí assertion trong test_constructor/test.js, test_properties/test.js và test_bigint/test.js, sau đó chạy các test đó trên Bun hoặc một runtime không phải V8 khác. Xác nhận hướng xử lý mà maintainer ưu tiên đối với các thông báo đặc thù của engine; được xem là hoàn tất khi các test xác minh hành vi đã nêu mà không yêu cầu nguyên văn chính xác của V8 và pass trên các runtime liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
bun, javascript, node.js
Lĩnh vực
testing-qa
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.