{"id":14957507,"url":"https://github.com/expressjs/domain-middleware","last_synced_at":"2025-10-30T20:21:56.657Z","repository":{"id":7434002,"uuid":"8772509","full_name":"expressjs/domain-middleware","owner":"expressjs","description":" `uncaughtException` middleware for connect, base on `domain` module.","archived":false,"fork":false,"pushed_at":"2013-04-12T09:25:31.000Z","size":216,"stargazers_count":102,"open_issues_count":13,"forks_count":15,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-01-29T10:35:25.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/expressjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-14T09:54:43.000Z","updated_at":"2024-07-10T04:01:39.000Z","dependencies_parsed_at":"2022-09-14T10:02:26.791Z","dependency_job_id":null,"html_url":"https://github.com/expressjs/domain-middleware","commit_stats":null,"previous_names":["fengmk2/domain-middleware"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expressjs%2Fdomain-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expressjs%2Fdomain-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expressjs%2Fdomain-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expressjs%2Fdomain-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/expressjs","download_url":"https://codeload.github.com/expressjs/domain-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237088479,"owners_count":19253565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:15:00.301Z","updated_at":"2025-10-19T07:31:26.802Z","avatar_url":"https://github.com/expressjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!CAUTION]\n\u003e **This repository is archived and no longer actively maintained.**\n\u003e\n\u003e We are no longer accepting issues, feature requests, or pull requests.\n\u003e For additional support or questions, please visit the [Express.js Discussions page](https://github.com/expressjs/express/discussions).\n\n\ndomain-middleware [![Build Status](https://secure.travis-ci.org/fengmk2/domain-middleware.png)](http://travis-ci.org/fengmk2/domain-middleware)\n=======\n\n![logo](https://raw.github.com/fengmk2/domain-middleware/master/logo.png)\n\n`uncaughtException` middleware for connect, base on `domain` module.\n\nTry to make a better [connect-domain](https://github.com/baryshev/connect-domain) module.\n\n[Warning: Don't Ignore Errors!](http://nodejs.org/docs/latest/api/domain.html#domain_warning_don_t_ignore_errors)\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/domain-middleware.html)\n\n## Install\n\n```bash\n$ npm install domain-middleware\n```\n\n## Usage\n\nUsually, [domain](http://nodejs.org/docs/latest/api/domain.html) usage goes hand-in-hand with the [cluster](http://nodejs.org/docs/latest/api/cluster.html) module, since the master process can fork a new worker when a worker encounters an error. \nPlease see [connect_with_cluster](https://github.com/fengmk2/domain-middleware/tree/master/example/connect_with_cluster) example.\n\nThis below code just for dev demo, don't use it on production env: \n\n```js\nvar http = require('http');\nvar connect = require('connect');\nvar domainMiddleware = require('domain-middleware');\n\nvar server = http.createServer();\nvar app = connect()\n.use(domainMiddleware({\n  server: server,\n  killTimeout: 30000,\n}))\n.use(function(req, res){\n  if (Math.random() \u003e 0.5) {\n    foo.bar();\n  }\n  setTimeout(function() {\n    if (Math.random() \u003e 0.5) {\n      throw new Error('Asynchronous error from timeout');\n    } else {\n      res.end('Hello from Connect!');\n    }\n  }, 100);\n  setTimeout(function() {\n    if (Math.random() \u003e 0.5) {\n      throw new Error('Mock second error');\n    }\n  }, 200);\n})\n.use(function(err, req, res, next) {\n  res.end(err.message);\n});\n\nserver.on('request', app);\nserver.listen(1984);\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2013 fengmk2 \u0026lt;fengmk2@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpressjs%2Fdomain-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpressjs%2Fdomain-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpressjs%2Fdomain-middleware/lists"}