首页 \ 问答 \ NodeJS:调试子进程导致不完整的运行或跳过的断点(NodeJS: Debugging child process causes incomplete runs or skipped breakpoints)

NodeJS:调试子进程导致不完整的运行或跳过的断点(NodeJS: Debugging child process causes incomplete runs or skipped breakpoints)

我正在使用WebStorm 8来调试父进程分叉子进程的场景,并向其发送消息。

为了使子进程可调试,我将--debug--debug-brk作为参数传递。

WebStorm成功接收了孩子的端口,但是我无法正确调试行为。

这是一个示例代码:

家长

var proc = require('child_process').fork('./child.js', [], {execArgv: ['--debug']});

proc.send({say: 'hello 1'});

setTimeout(function () {
    proc.send({say: 'hello 2'});
}, 3000);

孩子

console.log('child started');

process.on('message', function (msg) {
   console.log("child got message", msg);
});

1)在没有调试模式的情况下运行并且在没有--debug且没有--debug-brk的情况下 分叉时 ,代码运行良好,输出如下:

child started
child got message { say: 'hello 1' }
child got message { say: 'hello 2' }

2)当在调试模式下运行使用--debug-brk分叉时,代码行为不同 - 第一条消息永远不会到达进程,输出为:

debugger listening on port 62008
debugger listening on port 5858
child started
child got message { say: 'hello 2' }

3)当在调试模式下运行并且使用--debug分叉时,两个消息都会到达,但是只有第二条消息(hello 2)才会触发子消息处理程序内的断点。 输出是:

debugger listening on port 62022
debugger listening on port 5858
child started
child got message { say: 'hello 1' }
child got message { say: 'hello 2' }

基本上,这里似乎有两个问题:--debug-brk导致代码运行方式不同,而--debug导致跳过一些断点。

调试父级和子级的正确方法是什么,而不修改流并确保所有断点都停止运行?


I'm using WebStorm 8 to debug a scenario where a parent process forks a child, and sends it a message.

To make the child process debuggable, I'm passing --debug or --debug-brk as a parameter.

WebStorm successfully picks up the child's port, however I'm unable to have debugging behave correctly.

Here's a sample code:

Parent:

var proc = require('child_process').fork('./child.js', [], {execArgv: ['--debug']});

proc.send({say: 'hello 1'});

setTimeout(function () {
    proc.send({say: 'hello 2'});
}, 3000);

Child:

console.log('child started');

process.on('message', function (msg) {
   console.log("child got message", msg);
});

1) When running without debug mode and forking without --debug and without --debug-brk, the code runs well with the following output:

child started
child got message { say: 'hello 1' }
child got message { say: 'hello 2' }

2) When running in debug mode and forking with --debug-brk the code behaves differently - the first message never arrives to the process, and the output is:

debugger listening on port 62008
debugger listening on port 5858
child started
child got message { say: 'hello 2' }

3) When running in debug mode and forking with --debug both messages arrive, however a breakpoint inside the child's message handler is only fired for the second message (hello 2). The output is :

debugger listening on port 62022
debugger listening on port 5858
child started
child got message { say: 'hello 1' }
child got message { say: 'hello 2' }

Basically, there seems to be two issues here: --debug-brk causing code to run differently, and --debug causing some breakpoints to be skipped.

What is the correct way to debug both the parent and the child, without modifying the flow and ensuring that all breakpoints are stopped on?


原文:
更新时间:2022-09-09 20:09

最满意答案

如果是单向绑定,请使用第一种方式。

如果是双向绑定,则使用第二种方式,这意味着当用户更改DataGridView Cells时,更改将保留/保留在GetListSomeObjects()数据源中。

您尚未指定这是否是WPF,Winforms,Web,但您可以阅读有关BindingSourceOne,Two等等方式绑定的更多信息

双向

导致对source属性或target属性的更改以自动更新另一个属性。 此类绑定适用于可编辑表单或其他完全交互式UI方案。

单程

绑定源(源)更改时更新绑定目标(目标)属性。 如果绑定的控件是隐式只读的,则这种类型的绑定是合适的。 例如,您可以绑定到股票代码等来源。 或者,您的目标属性可能没有提供用于进行更改的控制接口,例如表的数据绑定背景颜色。 如果不需要监视目标属性的更改,则使用OneWay绑定模式可以避免TwoWay绑定模式的开销。

一次

在应用程序启动时或数据上下文更改时更新绑定目标。 如果您使用的数据适用于当前状态的快照或数据是真正静态的,则此类型的绑定是合适的。 如果要使用源属性中的某个值初始化目标属性并且事先不知道数据上下文,则此类型的绑定也很有用。 这实际上是OneWay绑定的一种更简单的形式,在源值不变的情况下提供更好的性能。

OneWayToSource

目标属性更改时更新source属性。 默认值使用绑定目标的默认模式值。 默认值因每个依赖项属性而异。 通常,用户可编辑的控件属性(例如文本框和复选框的属性)默认为双向绑定,而大多数其他属性默认为单向绑定。 确定依赖项属性是默认绑定单向还是双向的一种编程方法是使用GetMetadata获取属性的属性元数据,然后检查BindsTwoWayByDefault属性的布尔值。


Use the first way if its one-way binding.

Use the second way if its two-way binding, meaning when users change DataGridView Cells the changes will be kept/persisted in the GetListSomeObjects() datasource.

You haven't specified if this is WPF, Winforms, Web but you can read up more on BindingSource's and One, Two & etc Way Binding:

TwoWay

Causes changes to either the source property or the target property to automatically update the other. This type of binding is appropriate for editable forms or other fully-interactive UI scenarios.

OneWay

Updates the binding target (target) property when the binding source (source) changes. This type of binding is appropriate if the control being bound is implicitly read-only. For instance, you may bind to a source such as a stock ticker. Or perhaps your target property has no control interface provided for making changes, such as a data-bound background color of a table. If there is no need to monitor the changes of the target property, using the OneWay binding mode avoids the overhead of the TwoWay binding mode.

OneTime

Updates the binding target when the application starts or when the data context changes. This type of binding is appropriate if you are using data where either a snapshot of the current state is appropriate to use or the data is truly static. This type of binding is also useful if you want to initialize your target property with some value from a source property and the data context is not known in advance. This is essentially a simpler form of OneWay binding that provides better performance in cases where the source value does not change.

OneWayToSource

Updates the source property when the target property changes. Default Uses the default Mode value of the binding target. The default value varies for each dependency property. In general, user-editable control properties, such as those of text boxes and check boxes, default to two-way bindings, whereas most other properties default to one-way bindings. A programmatic way to determine whether a dependency property binds one-way or two-way by default is to get the property metadata of the property using GetMetadata and then check the Boolean value of the BindsTwoWayByDefault property.

相关问答

更多
  • 它正在工作的原因是DataGridView查找要在对象上显示的属性。 String有一个属性Length,因此它显示在网格上。 整数没有任何属性。 要使其工作,您可以创建一个具有int类型属性的新类。 然后,您可以将这些自定义对象的列表提供给DataGridView并控制显示的内容。 编辑: 这个答案有一个如何解决问题的例子。 The reason it's working the it does, is that DataGridView looks for properties to show on t ...
  • 我刚刚花了一个小时就遇到了类似的问题。 对我来说,答案竟然是尴尬的简单。 (dataGridViewFields.DataSource as DataTable).DefaultView.RowFilter = string.Format("Field = '{0}'", textBoxFilter.Text); I just spent an hour on a similar problem. For me the answer turned out to be embarrassingly simp ...
  • 最简单的方法是使用DataTable.Copy方法,该方法在新的DataTable中复制原始数据表的结构和数据 DataTable dt = (dataGridView1.DataSource as DataTable).Copy(); dt.Remove("xyz"); 当然,如果您的数据表包含大量记录,这可能会有问题,因为您在内存中将有两组相同的数据,并且复制过程不是立即的。 但是,如果不知道代码的目的是什么,我就无法提供替代方案。 出于这种行为的原因,简而言之,DataTable是一个引用变量,这意 ...
  • 您必须使用属性,而不是字段: class TermekRendeles { public int TermekID {get; set;} public string TermekNev {get; set;} public int Mennyiseg {get; set;} } You have to use Properties, not Fields: class TermekRendeles { public int TermekID {get; set;} public st ...
  • 试试这个代码。 您应该覆盖CellClick事件或在那里调用您的方法。 此代码以CellClick事件编写,不要与名称混淆 //This Code is written in CellClick Event not in CellContentClick (Don'tconfuse with signature) private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) ...
  • 可能有更好的方法,但一种可能性是简单地应用Linq Where语句来刷新您的DataSource 。 例如: private string folderPath = @"C:\Users\TULPAR\Desktop\elektrik projesi\proje\dosyalar\"; public Form1() { this.InitializeComponent(); this.dataGridView1.DataSource = new System.IO.DirectoryInf ...
  • 你可以使用BindingList例如: protected void GenerateButton_Click(object sender, EventArgs e) { BindingList SerialNumberList = new BindingList(); int x = 5; SerialNumberList.Add(new ListType(x.ToString())); gr ...
  • 我想这就是你想要的: DataGridViewComboBoxColumn colbox = new DataGridViewComboBoxColumn(); colbox.DataSource = products_list.ToList(); colbox.ValueMember = "Key"; colbox.DisplayMember = "Value"; dgvQuoteLines.Columns.Add( colbox ); I think this is what you want: Da ...
  • 如果是单向绑定,请使用第一种方式。 如果是双向绑定,则使用第二种方式,这意味着当用户更改DataGridView Cells时,更改将保留/保留在GetListSomeObjects()数据源中。 您尚未指定这是否是WPF,Winforms,Web,但您可以阅读有关BindingSource和One,Two等等方式绑定的更多信息 : 双向 导致对source属性或target属性的更改以自动更新另一个属性。 此类绑定适用于可编辑表单或其他完全交互式UI方案。 单程 绑定源(源)更改时更新绑定目标(目标)属性 ...
  • 我自己并没有这样做,但DataGridView不是密封的,所以你应该能够创建一个从它继承的新类。 创建一个新的事件“DataSourceChanging”,然后重写DataSource属性的Setter,以便它首先引发该事件, 然后实际设置父类的属性。 然后,您只需使用datagridview代替默认的DataGridview,然后将保存逻辑连接到DataSourceChanging。 I haven't done this myself, but DataGridView isn't sealed so ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。