Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain does not handle async function calls #16

Open
sakopqiu opened this issue Nov 4, 2021 · 0 comments
Open

Domain does not handle async function calls #16

sakopqiu opened this issue Nov 4, 2021 · 0 comments

Comments

@sakopqiu
Copy link

sakopqiu commented Nov 4, 2021

var http = require('http');
var connect = require('connect');
var domainMiddleware = require('domain-middleware');

var server = http.createServer();

var app = connect()
  .use(
    domainMiddleware({
      server: server,
      killTimeout: 30000,
    }),
  )
  .use(function (req, res) {
  // most handling logic is async in the real world
    async function f(res){
      if (Math.random() > 0.5) {
        throw new Error('Asynchronous error from timeout');
      } else {
        res.end('Hello from Connect!');
      }
    }
    f(); // this is not caught 
  })
  .use(function (err, req, res, next) {
    res.end(err.message);
  });

server.on('request', app);
server.listen(1984);


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant