Title: Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled · Issue #2107 · NativeScript/android · GitHub
Open Graph Title: Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled · Issue #2107 · NativeScript/android
X Title: Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled · Issue #2107 · NativeScript/android
Description: Summary In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit error. Why WorkerWrapper::OnNearHeapLimit is ...
Open Graph Description: Summary In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit error...
X Description: Summary In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit e...
Opengraph URL: https://github.com/NativeScript/android/issues/2107
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled","articleBody":"### Summary\n\nIn a debug build, once a DevTools session enables the `Debugger` domain on a worker target, that worker's `resourceLimits` stop being enforced and the parent never receives the heap-limit error.\n\n### Why\n\n`WorkerWrapper::OnNearHeapLimit` is registered with `AddNearHeapLimitCallback` in `PrepareV8Runtime`. It reports `ERR_WORKER_OUT_OF_MEMORY` to the parent and terminates the worker. V8 only invokes the most recently added near-heap-limit callback (`Heap::InvokeNearHeapLimitCallback` calls `near_heap_limit_callbacks_.back()`, `src/heap/heap.cc`). `V8Debugger::enable` adds its own callback (`src/inspector/v8-debugger.cc`), which shadows the worker's for as long as the Debugger domain stays enabled. That callback:\n\n- schedules an OOM break (`BreakReason::kOOM`), and\n- returns `HeapLimitForDebugging(initial_heap_limit)`, which raises the limit well past the configured `maxOldGenerationSizeMb`.\n\nSo while a debugger is attached to the worker, the worker either pauses on OOM in DevTools or keeps running above its cap. Either way `OnNearHeapLimit` never runs: the parent gets no `error` event, `terminate`/`exit` never follow, and code that relies on `resourceLimits` to contain a runaway worker behaves differently under the debugger than without it. Detaching restores the worker's callback (`V8Debugger::disable` removes the debugger's).\n\nRelease builds are unaffected (no inspector), and so are debug builds with no DevTools session, or with one that never enables `Debugger` on the worker target.\n\n### Expected\n\nPausing on OOM while debugging is reasonable and matches Chrome. But after the user resumes (or if the debugger's raised limit is also exhausted), the worker should still be reported and terminated as it is without a debugger. Possible directions:\n\n- Re-register `OnNearHeapLimit` after the worker's inspector session enables `Debugger`, so it stays last, and decide explicitly whether to break first.\n- Or chain: keep the debugger's break, but have the worker's handler run on resume, or once the debug allowance is exhausted.\n\n### Repro (sketch)\n\n1. Debug build of an app with a worker created with `resourceLimits: { maxOldGenerationSizeMb: 16 }` whose script allocates until it runs out of memory.\n2. Without DevTools: the parent gets the heap-limit `error`, and the worker ends.\n3. Attach Chrome DevTools to the worker target (which enables `Debugger`) and rerun: no `error` reaches the parent. The worker pauses on OOM, or, after resuming, keeps allocating past 16 MB.\n\nFound while reviewing #2070.\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-11-11T22:00:52Z","url":"https://github.com/NativeScript/android/issues/2107"}
| 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:f85ee338-ed89-2c63-a958-8aa97118d230 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9968:36A3E:13F3C83:1A9D53B:6B012ED1 |
| html-safe-nonce | 76f5ddcb8bd5027c8ea5d04bd11a404b7db2410c1b75eb4eca19d076560f2ab5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTY4OjM2QTNFOjEzRjNDODM6MUE5RDUzQjo2QjAxMkVEMSIsInZpc2l0b3JfaWQiOiI1MzMzNDY4MDY0NzI4MDM1MDI1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b30a14271372b5581484d537212dbb4d9a6df09b0dcdc6fa92246502fca77f0c |
| hovercard-subject-tag | issue:6337921472 |
| 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/android/2107/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b77ceb25061759618a3d620d97d69fe10cd438bc1c660bb662ab9edf8b52cbbd/NativeScript/android/issues/2107 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b77ceb25061759618a3d620d97d69fe10cd438bc1c660bb662ab9edf8b52cbbd/NativeScript/android/issues/2107 |
| og:image:alt | Summary In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit error... |
| 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/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 |
| 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