Skip to content

fix(inspector): pause debug-brk apps before they run - #534

Open
rigor789 wants to merge 1 commit into
feat/ios-stdio-forwardingfrom
fix/debug-brk-pause
Open

rigor789 wants to merge 1 commit into
feat/ios-stdio-forwardingfrom
fix/debug-brk-pause

Conversation

@rigor789

@rigor789 rigor789 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What is the current behavior?

With --nativescript-debug-brk, the app waits for a frontend, but it doesn't stop for it:

  • It's released about a second after the frontend connects, whatever the frontend has enabled by then.
  • The pause depends on __pauseOnNextRequire, which only fires on a require call. An app whose main bundle is an ES module doesn't make one, so a demo app never paused, and neither did the schedulePauseOnNextStatement call made alongside it.

What is the new behavior?

  • The app waits until the frontend sends Runtime.runIfWaitingForDebugger, which arrives after its Debugger.enable. Frontends that don't send it get 3 seconds.
  • It then stops on a one-line debugger; script before any app code runs, so breakpoints can still be set. Execution stops on that script rather than on the app's first line.
  • With no frontend, the existing 30-second timeout still lets the app run, without a pause.

The old check in require-factory.js is left in place but nothing sets the flag any more. Removing it means regenerating RuntimeBuiltins.cpp.

Testing

Scenario Result
CDP client, iPad on iPadOS 26.7 Waits, pauses, stays paused for 40 s, resumes, JS runs
CDP client, iOS 26.2 simulator Waits, pauses, resumes, JS runs
Client that never sends runIfWaitingForDebugger Pauses after about 3.7 s, runs on resume
No frontend Continues after the 30 s timeout
Real Chrome DevTools, headless, simulator App runs no code while attached, continues when DevTools closes

A real app (blackout) was also debugged on the iPad this way.

Possibly separate: after the startup pause, debugger; run through Runtime.evaluate paused, but the test client never saw a Debugger.resumed, and a later Debugger.pause did nothing. It didn't affect --debug-brk, and it isn't clear yet whether it's a runtime bug or the test.

Part of a stack

Base: #532. Needed for --debug-brk along with NativeScript/ios-device-lib#89 and NativeScript/nativescript-cli#6183.

The app was released about a second after a frontend connected, whatever it had enabled by then, and the pause relied on a require call, which an ES module app doesn't make, while schedulePauseOnNextStatement didn't stop on the main module. The app now waits for Runtime.runIfWaitingForDebugger, or 3 seconds for frontends that don't send it, then stops on a debugger statement before any app code runs.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 839b1e95-f289-43fb-80e6-56ec16ee4c42

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant