FAQ
I wrote a little module <https://github.com/mpareja/node-domainit> because
it allows me to execute a function that I don't control and handle errors
in a simple, uniform way. Do you all think that using a standard callback
style here makes sense? Or is this completely asinine because of
some intricacy of domains that I missed?

I've included the README below for your reading pleasure.

Cheers,

Mario Pareja


domainit - wrap a function with the safety of a domain

Wrap a function with the warm comfort of a node domain using standard
callbacks.

var assert = require('assert');var domainit = require('domainit');
function unsafe(cb) {
process.nextTick(function () {
throw new Error('Oops!');
});}
var safe = domainit(unsafe);safe(function (err) {
assert(err);
assert(err.message === 'Oops!');});

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Pedro Teixeira at Apr 4, 2013 at 12:55 pm
    I think it may be misleading, since that function is not a callback in the sense that it will not be called *once* and that there is no operation that has a definitive end.

    I think that an Event Emitter here is more standard and would play better with others.

    --
    Pedro

    On Thursday, April 4, 2013 at 7:54 AM, Mario Pareja wrote:

    I wrote a little module (https://github.com/mpareja/node-domainit) because it allows me to execute a function that I don't control and handle errors in a simple, uniform way. Do you all think that using a standard callback style here makes sense? Or is this completely asinine because of some intricacy of domains that I missed?

    I've included the README below for your reading pleasure.

    Cheers,

    Mario Pareja


    domainit - wrap a function with the safety of a domain

    Wrap a function with the warm comfort of a node domain using standard callbacks.

    var assert = require('assert'); var domainit = require('domainit'); function unsafe(cb) { process.nextTick(function () { throw new Error('Oops!'); }); } var safe = domainit(unsafe); safe(function (err) { assert(err); assert(err.message === 'Oops!'); });



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com).
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Matt at Apr 4, 2013 at 1:20 pm
    Why not just use domain.bind() on the function?

    On Thu, Apr 4, 2013 at 8:54 AM, Pedro Teixeira wrote:

    I think it may be misleading, since that function is not a callback in the
    sense that it will not be called *once* and that there is no operation that
    has a definitive end.

    I think that an Event Emitter here is more standard and would play better
    with others.

    --
    Pedro

    On Thursday, April 4, 2013 at 7:54 AM, Mario Pareja wrote:

    I wrote a little module <https://github.com/mpareja/node-domainit>because it allows me to execute a function that I don't control and handle
    errors in a simple, uniform way. Do you all think that using a standard
    callback style here makes sense? Or is this completely asinine because of
    some intricacy of domains that I missed?

    I've included the README below for your reading pleasure.

    Cheers,

    Mario Pareja


    domainit - wrap a function with the safety of a domain

    Wrap a function with the warm comfort of a node domain using standard
    callbacks.

    var assert = require('assert');var domainit = require('domainit');
    function unsafe(cb) {
    process.nextTick(function () {
    throw new Error('Oops!');
    });}
    var safe = domainit(unsafe);safe(function (err) {
    assert(err);
    assert(err.message === 'Oops!');});

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Arnout Kazemier at Apr 4, 2013 at 2:32 pm
    because that makes to much sense?
    On Thursday 4 April 2013 at 15:20, Matt wrote:

    Why not just use domain.bind() on the function?

    On Thu, Apr 4, 2013 at 8:54 AM, Pedro Teixeira (mailto:pedro.teixeira@gmail.com)> wrote:
    I think it may be misleading, since that function is not a callback in the sense that it will not be called *once* and that there is no operation that has a definitive end.

    I think that an Event Emitter here is more standard and would play better with others.

    --
    Pedro

    On Thursday, April 4, 2013 at 7:54 AM, Mario Pareja wrote:

    I wrote a little module (https://github.com/mpareja/node-domainit) because it allows me to execute a function that I don't control and handle errors in a simple, uniform way. Do you all think that using a standard callback style here makes sense? Or is this completely asinine because of some intricacy of domains that I missed?

    I've included the README below for your reading pleasure.

    Cheers,

    Mario Pareja


    domainit - wrap a function with the safety of a domain

    Wrap a function with the warm comfort of a node domain using standard callbacks.

    var assert = require('assert'); var domainit = require('domainit'); function unsafe(cb) { process.nextTick(function () { throw new Error('Oops!'); }); } var safe = domainit(unsafe); safe(function (err) { assert(err); assert(err.message === 'Oops!'); });



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com).
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs%2bunsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com (mailto:nodejs%2Bunsubscribe@googlegroups.com).
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com (mailto:nodejs@googlegroups.com)
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com)
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com (mailto:nodejs+unsubscribe@googlegroups.com).
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mario Pareja at Apr 8, 2013 at 2:33 pm
    Note: I am using domainit to execute tasks I don't control in a consistent
    and hopefully safer fashion.

    Whether or not Event Emitters make sense here was the gray area that made
    me post this thread. Pedro, your response was really helpful for me to
    clearly describe the use-case this module is intended to resolve, thanks!

    The domains API is powerful enough to handle a variety of scenarios.
    Domainit is meant to simplify one scenario: a finite task that may involve
    async work and, assuming no unhandled errors, notifies of completion
    through a standard callback function. I see domainit as a way of wrapping
    the execution of a potentially async, potentially failing operation in a
    conceptual try-catch while keeping true to the node standard callback
    conventions. The intention is to execute the callback exactly once.

    Matt & 3rdEden: I am aware of bind(). If the caller already had a domain
    instance handy, then that might make sense; otherwise, the caller needs to
    create a domain and attach to the error event. Furthermore, if the task
    being performed subsequently invokes your callback, your callback will be
    executed in the context of that task's domain. For this scenario, the
    domain's error handler wasn't likely meant to deal with errors in your
    callback - just errors in the task. You likely want a higher-level domain's
    error handler or the process' uncaughtException handler dealing with this.

    In my opinion, wrapping the unsafe function and using the standard callback
    approach makes things more composable. You could pass the resultant
    function to something like async.parallel, for instance.


    Cheers,


    Mario Pareja

    On Thursday, 4 April 2013 10:31:58 UTC-4, 3rdEden wrote:

    because that makes to much sense?

    On Thursday 4 April 2013 at 15:20, Matt wrote:

    Why not just use domain.bind() on the function?


    On Thu, Apr 4, 2013 at 8:54 AM, Pedro Teixeira <pedro.t...@gmail.com<javascript:>
    wrote:
    I think it may be misleading, since that function is not a callback in the
    sense that it will not be called *once* and that there is no operation that
    has a definitive end.

    I think that an Event Emitter here is more standard and would play better
    with others.

    --
    Pedro

    On Thursday, April 4, 2013 at 7:54 AM, Mario Pareja wrote:

    I wrote a little module <https://github.com/mpareja/node-domainit>because it allows me to execute a function that I don't control and handle
    errors in a simple, uniform way. Do you all think that using a standard
    callback style here makes sense? Or is this completely asinine because of
    some intricacy of domains that I missed?

    I've included the README below for your reading pleasure.

    Cheers,

    Mario Pareja


    domainit - wrap a function with the safety of a domain

    Wrap a function with the warm comfort of a node domain using standard
    callbacks.

    var assert = require('assert');var domainit = require('domainit');
    function unsafe(cb) {
    process.nextTick(function () {
    throw new Error('Oops!');
    });}
    var safe = domainit(unsafe);safe(function (err) {
    assert(err);
    assert(err.message === 'Oops!');});

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nod...@googlegroups.com <javascript:>
    To unsubscribe from this group, send email to
    nodejs+un...@googlegroups.com <javascript:>
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nod...@googlegroups.com <javascript:>
    To unsubscribe from this group, send email to
    nodejs+un...@googlegroups.com <javascript:>
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.




    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nod...@googlegroups.com <javascript:>
    To unsubscribe from this group, send email to
    nodejs+un...@googlegroups.com <javascript:>
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups
    "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to nodejs+un...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedApr 4, '13 at 12:45p
activeApr 8, '13 at 2:33p
posts5
users4
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase