javascript - 为什么 Node.js 中不推荐使用域 API?

标签 javascript node.js

为什么是 domain API在 Node.js 中已弃用?

我发现在传入 Web 请求的上下文中捕获错误而不是异常沸腾到进程级别很方便。

另外,现在可以使用域 API 的替代品吗?

最佳答案

Node.js issue #66: deprecate domains :

The problem isn't the user experience of domains, as you say the API is simple and users are generally happy with it, but the consequences domains have in maintenance and complications for the node.js core code – that seemingly simple API impacts all of the code base in a too negative way.

Domains in its current form must go. That's certain. What the alternative is, no one knows.

I don't get how we can deprecate something that covers a use case that cannot be covered otherwise, without providing clear (and ready) alternatives.

如果我们反过来说。我们知道域名必须离开,并且 很快就必须在某个时候删除。你喜欢那里吗 没有任何迹象?

链接的问题还提到(缺乏)替代方案。

关于javascript - 为什么 Node.js 中不推荐使用域 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33552400/

相关文章:

javascript - 检测浏览器和版本 - 没有 Modernizr

javascript - TypeError : this. props.* 不是函数

javascript回调函数,变量映射

javascript - 如何注册 video.js 插件

javascript - 如何在 Dynamodb 中存储对象?

html - 从 bodyParser 获取身份不明

node.js - 无法使用远程服务器在本地进行身份验证

javascript - 服务 worker 中的缓存未定义

node.js - 使用 babel-register `only` 选项

node.js - onlyoffice nextcloud “document could not be saved” nodeJS-postData错误