Skip to content

Instantly share code, notes, and snippets.

Last active December 20, 2019 18:50
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Node.js Callback Contract

Node.js Callback* Contract

(aka "errback" or "error first callback")

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
  4. Return value is ignored
  5. Must not throw / must pass resulting errors
  6. Must never be called more than once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment