domain-http-server icon indicating copy to clipboard operation
domain-http-server copied to clipboard

Shouldn't next() run after d.enter()?

Open SLaks opened this issue 12 years ago • 3 comments

I haven't verified this, but it looks like the current design won't actually run Express middleware inside the domain, since you only call d.enter() after running next().

Also, I don't think app.use(dhs) will work at all, since connect will think it's an error handler. (since it has arity 4; see https://github.com/senchalabs/connect/blob/master/lib/proto.js#L189-L190)

SLaks avatar Apr 19 '13 22:04 SLaks

Wow, I didn't realize that connect sniffs the arity of the function. That's kind of gross.

isaacs avatar Apr 19 '13 22:04 isaacs

Yes; that's really annoying. I'd like to write a connect / express wrapper that allows middleware / route handlers to return promises, and the arity sniffing makes it more complicated.

IIRC, you can't even set .length by hand to fake it, since it's readonly. (I didn't try defineProperty())

SLaks avatar Apr 19 '13 22:04 SLaks

just do this: https://github.com/brianc/node-domain-middleware/blob/master/index.js#L8

tjmehta avatar Apr 01 '15 20:04 tjmehta