nativescript-community / nativescript-vscode-extension

A Visual Studio Code Extension for NativeScript
https://www.nativescript.org/visual-studio-code
Apache License 2.0
82 stars 32 forks source link

Launch on iOS - iOS debugger disconnects after ~10 seconds for no apparent reason #298

Closed adrian-niculescu closed 3 months ago

adrian-niculescu commented 6 months ago

Environment

Result of echo 'y' | npx nativescript-envinfo

OS: macOS 14.3.1
CPU: (12) arm64 Apple M2 Pro
Shell: /bin/bash
node: 20.11.1
npm: 10.3.0
nativescript: 8.6.5

# android
java: 17.0.7
ndk: Not Found
apis: 32, 33, 34
build_tools: 33.0.0, 33.0.1, 34.0.0
system_images: 
  - android-28 | Google ARM64-V8a Play ARM 64 v8a
  - android-29 | Google Play ARM 64 v8a
  - android-30 | Google APIs ARM 64 v8a
  - android-30 | Google Play ARM 64 v8a
  - android-33 | Google APIs ARM 64 v8a
  - android-33 | Google Play ARM 64 v8a
  - android-34-ext8 | Google Play ARM 64 v8a
  - android-34 | Google APIs ARM 64 v8a
  - android-34 | Google Play ARM 64 v8a

# ios
xcode: 15.2/15C500b
cocoapods: 1.15.2
python: 3.11.7
python3: 3.11.7
ruby: 3.3.0
platforms: 
  - DriverKit 23.2
  - iOS 17.2
  - macOS 14.2
  - tvOS 17.2
  - visionOS 1.0
  - watchOS 10.2

Dependencies

"dependencies": {
  "@nativescript/core": "~8.6.2",
  "@nativescript/theme": "~3.0.2"
},
"devDependencies": {
  "@nativescript/android": "8.6.2",
  "@nativescript/ios": "8.6.3",
  "@nativescript/types": "~8.6.1",
  "@nativescript/webpack": "~5.0.18",
  "typescript": "~5.2.0"
}

Describe the bug

I let the NativeScript extension create the .vscode/launch.json file. Run the Launch on iOS configuration . It runs the app successfully, but then it disconnects automatically after ~ 10 seconds for no apparent reason. This replicates with both real devices (iPhone 12, iOS 16.1) and iOS Simulators (iOS 16.4, iOS 17.2). This does not replicate on Android.

To Reproduce

Create a simple NativeScript with the CLI

ns create testApp --ts
cd testApp
npm install
ns platform add ios
ns platform update ios

Open the app in Visual Studio Code. Go to Run and Debug. Let the NativeScript extension create the .vscode/launch.json file. Run the Launch on iOS configuration.

Expected behavior

The debugger should not disconnect after ~ 10 seconds.

Sample project

Sample project

Additional context

The OUTPUT window:

[NSDebugAdapter] Using tns CLI on path 'tns'

[NSDebugAdapter] Running tns command...

[NSDebugAdapter] Using iOS Team ID 'REDACTED', you can change this in the workspace settings.

[NativeScriptCli] execute: tns --analyticsClient VSCode debug ios --watch --teamId REDACTED
[NSDebugAdapter] Watching the tns CLI output to receive a connection token

Searching for devices...

Preparing project...

webpack is watching the files...

asset vendor.js 6.92 MiB [compared for emit] (name: vendor) (id hint: defaultVendor)
asset bundle.js 339 KiB [compared for emit] (name: bundle)
asset runtime.js 86.2 KiB [compared for emit] (name: runtime)
asset tns_modules/inspector_modules.js 1.22 KiB [compared for emit] (name: tns_modules/inspector_modules)
Entrypoint bundle 7.33 MiB = runtime.js 86.2 KiB vendor.js 6.92 MiB bundle.js 339 KiB
Entrypoint tns_modules/inspector_modules 7 MiB = runtime.js 86.2 KiB vendor.js 6.92 MiB tns_modules/inspector_modules.js 1.22 KiB
runtime modules 24.8 KiB 11 modules
orphan modules 13.5 KiB [orphan] 9 modules
modules by path ./node_modules/@nativescript/ 1.68 MiB 195 modules
modules by path ./node_modules/css-tree/ 317 KiB 113 modules
modules by path ./app/ 124 KiB 7 modules
modules by path ./node_modules/source-map/lib/*.js 36.3 KiB 6 modules
modules by path ./node_modules/reduce-css-calc/dist/ 131 KiB 5 modules
modules by path ./node_modules/postcss-value-parser/lib/*.js 12.5 KiB
  ./node_modules/postcss-value-parser/lib/index.js 607 bytes [built] [code generated]
  + 4 modules
modules by path ./node_modules/mdn-data/css/*.json 242 KiB
  ./node_modules/mdn-data/css/at-rules.json 11.6 KiB [built] [code generated]
  + 2 modules
+ 5 modules
webpack 5.90.2 compiled successfully in 1151 ms
Webpack compilation complete. Watching for file changes.

Updating runtime package.json with configuration values...

Project successfully prepared (ios)

File change detected. Starting incremental webpack compilation...

Type-checking in progress...

assets by status 7.34 MiB [cached] 4 assets
Entrypoint bundle 7.33 MiB = runtime.js 86.2 KiB vendor.js 6.92 MiB bundle.js 339 KiB
Entrypoint tns_modules/inspector_modules 7 MiB = runtime.js 86.2 KiB vendor.js 6.92 MiB tns_modules/inspector_modules.js 1.22 KiB
cached modules 2.78 MiB (javascript) 24.8 KiB (runtime) [cached] 358 modules
./app/ sync \.(xml%7Cjs%7C(?<%21\.d\.)ts%7Cs?css)$ 270 bytes [built]
webpack 5.90.2 compiled successfully in 53 ms

Webpack compilation complete. Watching for file changes.

Type-checking in progress...

No errors found.

Successfully transferred bundle.js on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.
Successfully transferred package.json on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.

Successfully transferred runtime.js on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.
Successfully transferred tns_modules on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.

Successfully transferred inspector_modules.js on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.

Successfully transferred vendor.js on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.

Restarting application on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE...

  [HMR][cd3ccbf9ba034b589abe] boot | HMR Enabled - waiting for changes...

  NativeScript debugger has opened inspector socket on port 18183 for org.nativescript.testApp.

'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector.

Setting up debugger proxy...
Press Ctrl + C to terminate, or disconnect.

Opened localhost 41000

To start debugging, open the following URL in Chrome:
devtools://devtools/bundled/inspector.html?ws=localhost:41000

Successfully synced application org.nativescript.testApp on device BBE3F6C9-BDDA-42EC-AB9F-EE7D67E1AEBE.

[NSDebugAdapter] Ready to attach to application on 41000

The DEBUG CONSOLE window:

Error when trying to require webpack.config.js file from path '/Users/adriann/Developer/SANDBOX/testApp/webpack.config.js'. Error is: Error: Cannot find module '/package.json'
Require stack:
- /Users/adriann/Developer/SANDBOX/testApp/node_modules/@nativescript/webpack/dist/helpers/project.js
- /Users/adriann/Developer/SANDBOX/testApp/node_modules/@nativescript/webpack/dist/helpers/dependencies.js
- /Users/adriann/Developer/SANDBOX/testApp/node_modules/@nativescript/webpack/dist/helpers/externalConfigs.js
- /Users/adriann/Developer/SANDBOX/testApp/node_modules/@nativescript/webpack/dist/index.js
- /Users/adriann/Developer/SANDBOX/testApp/webpack.config.js
- /Users/adriann/.vscode/extensions/nativescript.nativescript-0.12.3/out/debug-adapter/nativeScriptDebugAdapter.js
- /Users/adriann/.vscode/extensions/nativescript.nativescript-0.12.3/out/debug-adapter/nativeScriptDebug.js
- /[eval]

Note that this error pops up when using Launch on Android too, but the debugger does NOT disconnect there.

vallemar commented 6 months ago

Thanks @adrian-niculescu , this is a known issue that we will resolve in the next release, I hope it will be this week. @rigor789 @farfromrefug , do we have any progress to be able to publish the version?

billfroelich commented 5 months ago

@vallemar Any update on when the fix for this will be released?

jitendrakansal commented 5 months ago

@vallemar Could you update if the fix is already available?

vallemar commented 3 months ago

Fixed in v0.12.4 https://github.com/nativescript-community/nativescript-vscode-extension/pull/297 @billfroelich @jitendrakansal