GithubHelp home page GithubHelp logo

node-in-debugging's Issues

3.6节执行结果有误

3.6.4节第六题的结果4和7的顺序颠倒了。在node v12.13.0版本中的顺序为:9 5 8 1 4 7 3 6 2

前者表述的含义setTimeout和setInterval在timers阶段执行,后者表示setTimeout和setInterval在poll阶段执行,是否自相矛盾?

你的文章中写道下面的两个, 前者表述的含义setTimeout和setInterval在timers阶段执行,后者表示setTimeout和setInterval在poll阶段执行,是否自相矛盾?

每个阶段(phase)的作用:timers:执行 setTimeout() 和 setInterval() 中到期的 callback。

poll 阶段主要有两个功能:
当 timers 的定时器到期后,执行定时器(setTimeout 和 setInterval)的 callback。
执行 poll 队列里面的 I/O callback。

我们看nodejs官方的解释: 这个解释的含义应该是: poll阶段会取回所有的io事件, 执行相关的io回调(换句话说:是除了timers和setimmediate之外的所有事件)。 按照官方的解释,poll阶段并不会执行定时器相关的回调。

poll: retrieve new I/O events; execute I/O related callbacks (almost all with the exception of close callbacks, the ones scheduled by timers, and setImmediate()); node will block here when appropriate. https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/

4.2.4 process._debugProcess 关闭debug?

在 4.2.4 process._debugProcess 章节中

打开新的终端,运行:node -e "process._debugProcess(53911)" 启动调试后,调试结束后 怎么把debug调试 关闭掉呢 ?在不停止node进程的情况下呢 ?

我在 process 的方法中 找到了 process._debugEnd 方法,但是没有起作用的啊

如何调试 ES6 modules ?

下面是我的理解:

调试 ES6 modules,现在的方案是先编译成 es5,加上 sourcemap 进行调试。
如果要直接调试,可以使用 babel-node,但是在调试上下文中变量有问题。
使用 nodejs 原生 es6 modules 调试理论上没有问题。

NODE_OPTIONS='--experimental-modules --loader ./custom-loader.mjs' node —inspect-brk x.js
# custom-loader.js 支持加载 nodejs 内置模块,省略 js 后缀的 es6 模块 以及 mjs 后缀的 es6 模块

但是 Chrome 中调试有可能不能在 Filesystem 中看到文件,不方便打断点(需要添加 debugger 语句)
可以在 vscode 中调试:launch.json 中添加 runtimeArgs

写的很不错

整个 Node.js 的调试以及分析,不同工具都有,例子也很详细,感谢提供如此棒的文档。

我们是淘宝的 MidwayJs 团队,最近出品了新的 Node.js 应用管理器 Pandora.js,可以在一定程度上帮助应用开发和调试,可以试试,如有不足也可以反馈给我们。

链接如下:https://github.com/midwayjs/pandora/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.