Skip to content

Bug in Dart program runtime #36762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vscodenpa opened this issue Dec 30, 2023 · 2 comments
Open

Bug in Dart program runtime #36762

vscodenpa opened this issue Dec 30, 2023 · 2 comments

Comments

@vscodenpa
Copy link
Owner

VS Code Version:

Version: 1.85.1 (user setup)
Commit: https://github-com/microsoft/vscode/commit/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:49:37.021Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045

OS Version: Windows 10

Steps to Reproduce:
Run this Dart code in VS CODE:

import 'dart:io';

void main() {
var isLoopContinue = true;
var attempts = 0;

while (isLoopContinue == true) {
stdout.writeln("Enter email:");
var email = stdin.readLineSync();
stdout.writeln("Enter password:");
var password = stdin.readLineSync();
if (email == 'admin-gmail.com' && password == "123456") {
print("Login successfully");
isLoopContinue = false;
} else {
attempts++;
if (attempts > 3) {
isLoopContinue = false;
print('Your account has been blocked!');
} else {
print('Invalid credentials. Please try again.');
}
}
}
}

Output:
Enter email:
"HERE IS THE EMAIL INPUT , WE WROTE" //AND THEN ERRORS BELOW
Unknown evaluation response type: null
-0 DartDebugAdapter.evaluateRequest (package:dds/src/dap/adapters/dart.dart:1076:7)
https://github-com/microsoft/vscode/-/1 BaseDebugAdapter.handle (package:dds/src/dap/base_debug_adapter.dart:141:20)
https://github-com/microsoft/vscode/-/2 BaseDebugAdapter.handleIncomingRequest (package:dds/src/dap/base_debug_adapter.dart:447:7)
https://github-com/microsoft/vscode/-/3 BaseDebugAdapter._handleIncomingMessage (package:dds/src/dap/base_debug_adapter.dart:295:7)
https://github-com/microsoft/vscode/-/4 ByteStreamServerChannel._readMessage (package:dds/src/dap/protocol_stream.dart:82:18)
https://github-com/microsoft/vscode/-/5 ByteStreamServerChannel.listen. (package:dds/src/dap/protocol_stream.dart:53:24)
https://github-com/microsoft/vscode/-/6 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
https://github-com/microsoft/vscode/-/7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
https://github-com/microsoft/vscode/-/8 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
https://github-com/microsoft/vscode/-/9 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
https://github-com/microsoft/vscode/-/10 _PendingEvents.schedule. (dart:async/stream_impl.dart:591:7)
https://github-com/microsoft/vscode/pull/11 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
https://github-com/microsoft/vscode/-/12 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
https://github-com/microsoft/vscode/-/13 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
https://github-com/microsoft/vscode/-/14 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

Code RUNS OK when we run this code via CMD by running this command "dart run filename.dart"

@sarvesh2847
Copy link

The vscode default debug console does not accept user input. To debug a program requiring user input you will have to set: Preferences > Dart > Run and Debug > Dart: Cli Console to Terminal (or alternatively External Terminal).

@sarvesh2847
Copy link

sarvesh2847 commented Aug 11, 2024

By default, the application runs without a terminal. The "Debug Console" you are using is a REPL (Read-Eval-Print Loop) that processes expressions and displays the results.

If you need to read input from stdin, you'll have to configure the extension to run inside a terminal instead. However, this mode may have limited functionality since the debugger will have less access to the process output.

There are two ways to run the application in the terminal: one is by setting the console field in a launch.json file, and the other is by configuring the dart.cliConsole setting in your VS Code User or Workspace Settings, depending on whether you want the change to apply to all projects or just this one.

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

No branches or pull requests

2 participants