node.js-domains

What is the difference between local and global module in Node.js? When to use local and global module?

﹥>﹥吖頭↗ 提交于 2020-02-18 07:21:10
问题 We can access local module using require function but cannot access global module through it. I read somewhere that to use global module we need to make it local then import it through require function. So if we cannot access global module directly, then what is the need of using it. 回答1: You should: Install a module locally if you're going to require() it. Install a module globally if you're going to run it on the command line. 回答2: I think in my opinion the modules which you are going to

What is the difference between local and global module in Node.js? When to use local and global module?

。_饼干妹妹 提交于 2020-02-18 07:20:49
问题 We can access local module using require function but cannot access global module through it. I read somewhere that to use global module we need to make it local then import it through require function. So if we cannot access global module directly, then what is the need of using it. 回答1: You should: Install a module locally if you're going to require() it. Install a module globally if you're going to run it on the command line. 回答2: I think in my opinion the modules which you are going to

Unable to call dispose on domain at appropriate time

狂风中的少年 提交于 2020-01-03 18:57:33
问题 I'm having an issue with the domain module. Currently, I'm trying to catch any uncaught errors that are thrown in a request. Using an express middleware and domains. All requests are routed through this function before calling next and moving on to it's proper route. app.use (req, res, next) -> domain = createDomain() domain.on "error", (err) -> res.send(500) domain.dispose() domain.enter() next() The problem is, how do I dispose of the domain if an error is never thrown? I could hoist the

Unable to call dispose on domain at appropriate time

▼魔方 西西 提交于 2020-01-03 18:57:25
问题 I'm having an issue with the domain module. Currently, I'm trying to catch any uncaught errors that are thrown in a request. Using an express middleware and domains. All requests are routed through this function before calling next and moving on to it's proper route. app.use (req, res, next) -> domain = createDomain() domain.on "error", (err) -> res.send(500) domain.dispose() domain.enter() next() The problem is, how do I dispose of the domain if an error is never thrown? I could hoist the

NodeJS Domains and expressjs

萝らか妹 提交于 2019-12-21 06:57:17
问题 Newbie to ExpressJS question: I am planning on creating a fairly simple (but large) ExpressJS project that responds to REST requests and does read-only DB responses. I have read up about NodeJS domains for capturing errors, but it is not clear to me that I need that for this project. My testing seems to indicate that even in the worst uncaught throws and crashes, only the individual REST request fails, and not the whole server. Am I correct? NodeJS Domain API: http://nodejs.org/api/domain

Why NodeJS domains documentation code tries to terminate the process?

a 夏天 提交于 2019-12-11 04:25:05
问题 In the official NodeJS documentation there is code example where process tries to exit gracefully when there was exception in domain (it closes connections, waits for some time for other requests and then exits). But why just not send the 500 error and continue to work? In my application I want to throw some expected Errors (like FrontEndUserError) when user input is not valid, and catch these exceptions somewhere in middleware to send pretty error message to client. With domains it very easy

Node, Express, domains, uncaught exceptions - still lost

五迷三道 提交于 2019-12-06 21:06:36
问题 I have been reading for hours on exception handling in Node. I understand the cons of using uncaughtException , I understand that shutting down the process is good for preventing any "unknown state" where "anything can happen". I understand that using domains is the way to go, and I understand how to properly implement domains, specifically Explicit Binding... ...but I'm still not getting any results for just basic error handling. I would like to be able to just catch any uncaught exceptions

Node, Express, domains, uncaught exceptions - still lost

对着背影说爱祢 提交于 2019-12-05 02:50:26
I have been reading for hours on exception handling in Node. I understand the cons of using uncaughtException , I understand that shutting down the process is good for preventing any "unknown state" where "anything can happen". I understand that using domains is the way to go, and I understand how to properly implement domains, specifically Explicit Binding ... ...but I'm still not getting any results for just basic error handling. I would like to be able to just catch any uncaught exceptions for the purpose of logging. I don't mind killing the process or anything else deemed "undesirable". I

NodeJS Domains and expressjs

这一生的挚爱 提交于 2019-12-03 22:45:23
Newbie to ExpressJS question: I am planning on creating a fairly simple (but large) ExpressJS project that responds to REST requests and does read-only DB responses. I have read up about NodeJS domains for capturing errors, but it is not clear to me that I need that for this project. My testing seems to indicate that even in the worst uncaught throws and crashes, only the individual REST request fails, and not the whole server. Am I correct? NodeJS Domain API: http://nodejs.org/api/domain.html#domain_class_domain (Obviously the reason I ask is that domain functionality is hard to implement

How to use Node.js 0.8.x domains with express?

这一生的挚爱 提交于 2019-12-03 04:54:22
问题 How can I create Express/Connect middleware which wrap each request in its own domain? 回答1: This set of slides on Speaker Deck gives a succinct overview: Domains in node 0.8 Express middleware code from the slides: var createDomain = require('domain').create; app.use(function(req, res, next) { var domain = createDomain(); domain.on('error', function(err) { // alternative: next(err) res.statusCode = 500; res.end(err.message + '\n'); domain.dispose(); }); domain.enter(); next(); }); 回答2: UPDATE