Title: feat: add AbortController and AbortSignal by edusperoni · Pull Request #2025 · NativeScript/android · GitHub
Open Graph Title: feat: add AbortController and AbortSignal by edusperoni · Pull Request #2025 · NativeScript/android
X Title: feat: add AbortController and AbortSignal by edusperoni · Pull Request #2025 · NativeScript/android
Description: Mirrors NativeScript/ios#447 on Android (same three commits, same file shapes). What Installs the DOM Standard's abort primitives as globals in every isolate (main and workers), modeled on Node's internal/abort_controller.js: AbortController — controller.signal (stable identity) and controller.abort(reason?). AbortSignal extending the runtime's EventTarget, with aborted, reason, throwIfAborted(), the abort event, and onabort with HTML event-handler semantics. new AbortSignal() throws TypeError: Illegal constructor. Statics: AbortSignal.abort(reason?), AbortSignal.timeout(delay) (Node's delay validation), and AbortSignal.any(signals) (composite flattening, first-aborted-reason-wins, spec-ordered state flips before events fire). WebIDL-shaped interfaces: enumerable members, Symbol.toStringTag, brand-checked accessors (via private fields). How The builtin (test-app/runtime/src/main/cpp/js/abort-signal.js) runs from Events::Init immediately after the Event/EventTarget builtin it is layered on. This PR also introduces a sixth fixed wrapper parameter, internals: one plain per-isolate object (a BuiltinRealm slot in the per-runtime state) handed identically to every builtin and reachable from nowhere app code can see — the private channel for cross-builtin capabilities. Both previously ad-hoc channels now ride it: the kListenerChanged hook key (events → abort-signal) and setListenerErrorReporter (error-events → events), replacing the _installListenerErrorReporter one-shot that transiently sat on the app-reachable global target. Documented in the js README as an interim mechanism, with the intended end-state being a Node-style private internal-module tier (require("internal/…") for builtins only). RangeError, NumberIsInteger, WeakRef, and FinalizationRegistry are added to primordials (and the eslint restriction lists). GC contract (Node-equivalent, documented in docs/abort-signal.md) Internal references never keep an unobservable signal alive and never drop an observable abort: timeout() timers close over a WeakRef; a FinalizationRegistry cancels the pending native timer if the signal is collected first. any() links are WeakRefs in both directions with prune registries, so per-request composites never accumulate on a long-lived source, and a composite whose sources all died stops being retained. A gcPersistentSignals set strong-holds exactly the signals whose abort someone can still observe: live timeout signals and non-empty composites while they have abort listeners, plus timeout sources a composite follows until their timer fires. The listener accounting comes from a new symbol-keyed listener-mutation hook in events.js (called from add, remove, and the once-splice during dispatch), published on the builtin-only internals channel — so it cannot be bypassed via a captured EventTarget.prototype.addEventListener. Deviation from Node No DOMException in this runtime: default reasons are Error instances with name patched to "AbortError" / "TimeoutError", the same stand-in performance.js and structured-clone.js use. Tests 20 behavioral specs: illegal constructor, state-flips-before-event ordering, reason identity (including null), throwing listeners not stopping dispatch, once listeners, onabort set/replace/clear, delay validation, any() flattening/dedup/no-double-fire, arbitrary iterables, toStringTag, brand checks. 8 GC specs driven by __collect(): a finalization-registry substrate canary, collectability of unobserved timeout signals and composites, survival (and delivery) for listened ones, a composite keeping a dropped timeout source alive until it fires, release of a listened composite once its last source dies, and release on last-listener removal. The spec files are byte-identical to the iOS suite; the only source divergence from iOS is one comment line naming the Android init path (PrepareV8Runtime). Summary by CodeRabbit New Features Added global AbortController and AbortSignal APIs. Supports abort events, custom reasons, throwIfAborted(), timeouts, and combining multiple signals. Added validation and WebIDL-compatible interface behavior. Bug Fixes Improved cleanup of unused timeout and composite signals to reduce unnecessary resource retention. Documentation Added comprehensive API documentation, including behavior, error handling, and garbage-collection considerations. Tests Added extensive coverage for lifecycle, propagation, validation, events, errors, and cleanup behavior.
Open Graph Description: Mirrors NativeScript/ios#447 on Android (same three commits, same file shapes). What Installs the DOM Standard's abort primitives as globals in every isolate (main and workers), modeled on Node...
X Description: Mirrors NativeScript/ios#447 on Android (same three commits, same file shapes). What Installs the DOM Standard's abort primitives as globals in every isolate (main and workers), modeled on ...
Opengraph URL: https://github.com/NativeScript/android/pull/2025
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cc3cb62c-3bdc-71e0-769b-e8483a6fb776 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BDC8:22DB35:1EA994F:2722597:6B0154E1 |
| html-safe-nonce | 1e8cc9f2a3352c07fe67229f713f2d8d614b8c02ae952e714e1d1b76e2fce627 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCREM4OjIyREIzNToxRUE5OTRGOjI3MjI1OTc6NkIwMTU0RTEiLCJ2aXNpdG9yX2lkIjoiMzU2NDUwMjc2OTcxOTkyMjg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b96fc72d2af0a4fd94af7ba8b9231e7a196a5c2eda963a0b7b4bb9bdfaf26a02 |
| hovercard-subject-tag | pull_request:4350613001 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/android/pull/2025/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | Mirrors NativeScript/ios#447 on Android (same three commits, same file shapes). What Installs the DOM Standard's abort primitives as globals in every isolate (main and workers), modeled on Node... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width