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
Commit d888aad
Browse filesBrowse the repository at this point in the historyBrowse files
fix(runtime): same error handling in Debug and Release (#605)
* fix(runtime): throw a TypeError for invalid method receivers in every build
A native method or accessor called on a receiver with no native object, or
on a wrapper that is not an Objective-C instance (an interop.Pointer, a
Reference), threw a JS error only when RuntimeConfig.IsDebug was set and hit
tns::Assert otherwise, so the same JS aborted a Release app. Both cases now
throw a catchable TypeError naming the method, class and selector.
* fix(test): fail run_tests.sh on failing specs and add --configuration
XCTest passes once the app delivers its junit report, whatever the report
says, and the script discarded verify-junit-xml's status, so a run with
failing specs exited 0. The script now exits non-zero when the report is
missing or records a failure, exporting the attachments without xcparse when
it is not installed.
-c/--configuration Debug|Release builds the suite in that configuration; a
Release TestRunner also starts the runtime with IsDebug off.
* fix(runtime): log and abort from tns::Assert the same way in every build
Release builds ran a bare assert(condition): no reason, no native or JS
stack, and a check that NDEBUG would compile out. tns::Assert now has one
path for every build: it logs the failure, the reason, the native backtrace
and, when the isolate is entered on the calling thread, the JS stack, then
calls abort().
* refactor(runtime): remove the logRuntimeDetail write-value checks and traces
The logRuntimeDetail app config key enabled, only in a runtime compiled with
DEBUG (never the shipped framework), a trace of every method call and object
write plus write-value checks that aborted on conversions every other build
performs. Remove the key's readers, the checks and their helpers, and the
now unused tns::StopExecutionAndLogStackTrace.
* fix(runtime): reject non-native receivers of native instance members
An instance method whose `this` had no internal fields was sent to the class
instead: NSObject.prototype.isEqual.call({}, x) ran +[NSObject isEqual:], and
an instance property getter returned undefined. Instance methods now have
their own callback, and they and instance property accessors share one rule:
a native class constructor receiver makes a class-side call, any other
receiver must be a native object, or the call throws "Cannot call method ...
on a receiver that is not a native object". Class methods are unchanged.
Reading a native instance property on a prototype object now throws too.
* feat(runtime): add tns::Fatal and NS_CHECK/NS_DCHECK/NS_UNREACHABLE
Checks.h holds the runtime's error-handling policy and one fatal path,
tns::Fatal, which logs the location, the message, the native backtrace and,
when an isolate is entered on the calling thread, the JS stack, then aborts.
- NS_CHECK(cond, message): on in every build.
- NS_DCHECK(cond) / NS_DCHECK_MSG(cond, message): on while NS_DCHECK_IS_ON,
which defaults to 1 in DEBUG and AddressSanitizer builds and 0 otherwise.
When off, the condition is compiled but never evaluated.
- NS_UNREACHABLE(message).
tns::Assert keeps its call signature and forwards to tns::Fatal with its
caller's file and line. Node-API's v8impl::OnFatalError reports through
tns::Fatal too.
* fix(runtime): throw instead of aborting for bad native constructor and alloc calls
A native class constructor called without new (NSObject(), Reflect.apply)
and alloc() called with arguments hit tns::Assert. They now throw a
TypeError. Constructing a protocol (new NSCopying()) throws a TypeError, and
constructing a class that metadata lists but the runtime does not load throws
an Error, instead of reaching ConstructObject without a class.
* fix(runtime): throw instead of aborting for invalid extend() and __extends arguments
ClassBuilder::ExtendCallback asserted its arguments, so NSObject.extend()
with no or a non-object first argument, or an unbound call, aborted the
process. It now throws a TypeError for a receiver that is not a function,
a missing or non-object first argument, and a second argument that is
neither an object nor null/undefined. An exception thrown while reading
the options' name propagates to JS, and an implementation object whose
prototype cannot be set (for example a frozen one) throws a TypeError
instead of aborting.
The native __extends callback hands any base that is not a native class
(including other native wrapper types) to the base __extends function,
propagates that function's exceptions instead of crashing on
ToLocalChecked, and throws a TypeError when the derived side is not a
constructor function.
* fix(runtime): accept a Proxy around a native class as a native accessor receiver
Native property getters and setters rejected new Proxy(NSObject, {})
before the class-side normalization, while the constructor itself and
native instance methods accept it as a class-side call. Both accessor
paths now let ResolveProxyReceiver admit a class target. Revoked proxies
and proxies around non-native objects still throw a TypeError.
* fix(runtime): reject a non-extensible extend() implementation before registering its class
extend() set the implementation object's prototype only after GetExtendedClass had registered the native class, so a frozen implementation threw with the class already registered under the requested name: a corrected retry got a suffixed name while native lookup of the requested one found the failed class. The prototype change is now probed before registration and undone at once, since member discovery reads through the original prototype; the later assignment keeps its check.
* ci: skip the Catalyst job's report extraction when run_tests.sh already did it
run_tests.sh now extracts the junit report from the result bundle itself, and a second export-test-attachments.sh run into the same folder fails on its existing manifest.json.
* fix(runtime): keep a Proxy implementation's prototype through the extend() probe
v8::Object::GetPrototype() does not reach a Proxy's target while SetPrototype() forwards to it, so restoring after the probe dropped the target's prototype, and with it an inherited Symbol.iterator, before member discovery. A Proxy implementation skips the early probe; the later prototype assignment still rejects a frozen one.
0 commit comments