Title: worker.terminate() is a no-op during entry evaluation, and terminating there wedges teardown · Issue #445 · NativeScript/ios · GitHub
Open Graph Title: worker.terminate() is a no-op during entry evaluation, and terminating there wedges teardown · Issue #445 · NativeScript/ios
X Title: worker.terminate() is a no-op during entry evaluation, and terminating there wedges teardown · Issue #445 · NativeScript/ios
Description: Found while completing #443's pump-termination item (three empirical rounds on the #444 branch); target semantics below are verified on Android, where terminate-during-entry works (android#2021 @ 351bef64, spec-proven with terminate land...
Open Graph Description: Found while completing #443's pump-termination item (three empirical rounds on the #444 branch); target semantics below are verified on Android, where terminate-during-entry works (android#2021 @ 3...
X Description: Found while completing #443's pump-termination item (three empirical rounds on the #444 branch); target semantics below are verified on Android, where terminate-during-entry works (android#2021...
Opengraph URL: https://github.com/NativeScript/ios/issues/445
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"worker.terminate() is a no-op during entry evaluation, and terminating there wedges teardown","articleBody":"Found while completing #443's pump-termination item (three empirical rounds on the #444 branch); target semantics below are verified on Android, where terminate-during-entry works (android#2021 @ 351bef64, spec-proven with terminate landing 0-1ms into the entry body).\n\n## The defect (iOS)\n\n**The no-op**: `WorkerWrapper::workerIsolate_` is assigned only after the background looper's `func()` returns — and `func()` is where entry evaluation (the pumped module-graph load, any top-level-await park) runs. `Terminate()` bails on the null isolate, so for a worker still inside its entry, `worker.terminate()` does nothing: no `TerminateExecution`, no termination-requested flag. The pump bails landed in #444 engage only once the worker has a published isolate — the parked-entry scenario #443's pump item describes is unreachable on iOS for this reason.\n\n**The wedge**: publishing the isolate early (via a separate atomic, drain-guard semantics untouched) makes `Terminate()` genuinely fire mid-entry — and the suite then hangs past 600s in teardown. That attempt was reverted on #444's branch: shipping it would convert a silent no-op into a hang. The comment at `WorkerWrapper.mm` (Terminate) records the gap at the site.\n\n## Target semantics — what correct terminate-during-entry looks like\n\nVerified end-to-end on Android (trace + spec); the fix here must satisfy all six:\n\n1. **Prompt pump exit via a termination-requested flag**, not the V8 probe alone — `IsExecutionTerminating` is a mid-unwind probe and a parked pump runs no JS. (Already converged: android e11c9c30 / iOS's requested-flag in #444; iOS's flag is currently unreachable mid-entry because of the no-op above.)\n2. **Termination never masquerades**: the evaluator checks termination BEFORE its timeout branch (never \"Top-level await timed out\"), and exception construction has an explicit HasTerminated/empty-Message branch (never an entry rejection with a fabricated message).\n3. **No onerror on a dying worker**: the error router early-returns on the wrapper's terminating flag — a terminated entry produces neither worker-scope `onerror` nor a parent error event. Terminate is not an error.\n4. **Everything after the bail runs no JS and tolerates empty answers**: the settle-gate's capability re-`Evaluate()` returns empty on a terminating isolate and must fall through inertly; the teardown chain drops loop entries and releases handles only, never consuming an unchecked Maybe before `Dispose`.\n5. **Error-report building must be termination-safe**: anything between the bail and disposal that formats messages/stacks must read through `FromMaybe`/`IsEmpty`, never `ToChecked`/`ToLocalChecked` — the termination interrupt can materialize inside the reporter itself (`ToDetailString` runs JS). Android hit exactly this CHECK-abort and fixed it in 351bef64; iOS's exception/message formatters need the same audit as part of this work.\n6. **The window is real, not theoretical**: on Android the spec's terminate landed 0-1ms into the entry body on every iteration. Any fix must be spec-proven with the same shape (worker .mjs entry parked in TLA, terminated mid-pump, repeated iterations).\n\n## Scope\n\nA worker-lifecycle design pass: early isolate publication paired with a teardown path that tolerates termination landing inside entry evaluation (the pumped graph load, the TLA park, and the queue-arm-before-isolate window are all live during `func()`), plus the rule-5 formatter audit. Cross-runtime contract: the six rules above should hold identically on both platforms; Android already conforms.\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-08-20T16:09:39Z","url":"https://github.com/NativeScript/ios/issues/445"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f8c5679c-225d-d5d5-acce-08a333a8b6a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A470:134361:17E0001:1F665CA:6B01383A |
| html-safe-nonce | 4a889cb5bf4a5584f86f3462fa16109b9d84c422db70076ab7a9096e64973985 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDcwOjEzNDM2MToxN0UwMDAxOjFGNjY1Q0E6NkIwMTM4M0EiLCJ2aXNpdG9yX2lkIjoiNDExMzI1NDI4MzgzNzc4MjA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e2fd3474277e8f4d66d29c1b50bfa7b7b1acd1a0619f5de74e8b549067083a03 |
| hovercard-subject-tag | issue:5205501765 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/NativeScript/ios/445/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9c9b830e2d8d2f8eade279da96ba127ec21f7a09af9f18dd708a26c3b702550d/NativeScript/ios/issues/445 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9c9b830e2d8d2f8eade279da96ba127ec21f7a09af9f18dd708a26c3b702550d/NativeScript/ios/issues/445 |
| og:image:alt | Found while completing #443's pump-termination item (three empirical rounds on the #444 branch); target semantics below are verified on Android, where terminate-during-entry works (android#2021 @ 3... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edusperoni |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/ios git https://github.com/NativeScript/ios.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 172934359 |
| octolytics-dimension-repository_nwo | NativeScript/ios |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172934359 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/ios |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| 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 |
| react-app-name | issues |
Links:
Viewport: width=device-width