Skip to content

Commit

Permalink
Merge pull request kriskowal#591
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Nov 10, 2014
2 parents f43ca54 + 46e3d98 commit e3aec4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.1.0

- Adds support for enabling long stack traces in node.js by setting
environment variable `Q_DEBUG=1`.
- Introduces the `tap` method to promises, which will see a value
pass through without alteration.
- Use instanceof to recognize own promise instances as opposed to
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,15 @@ stack trace! This is very helpful for debugging, as otherwise you end up getting
only the first line, plus a bunch of Q internals, with no sign of where the
operation started.

In node.js, this feature can also be enabled through the Q_DEBUG environment
variable:

```
Q_DEBUG=1 node server.js
```

This will enable long stack support in every instance of Q.

This feature does come with somewhat-serious performance and memory overhead,
however. If you're working with lots of promises, or trying to scale a server
to many users, you should probably keep it off. But in development, go for it!
Expand Down
5 changes: 5 additions & 0 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ Q.nextTick = nextTick;
*/
Q.longStackSupport = false;

// enable long stacks if Q_DEBUG is set
if (typeof process === "object" && process && process.env && process.env.Q_DEBUG) {
Q.longStackSupport = true;
}

/**
* Constructs a {promise, resolve, reject} object.
*
Expand Down

0 comments on commit e3aec4d

Please sign in to comment.