Skip to content

Add trace flag for configuring long stack traces #713

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

Merged
merged 1 commit into from
Jan 17, 2014
Merged

Add trace flag for configuring long stack traces #713

merged 1 commit into from
Jan 17, 2014

Conversation

dougwilson
Copy link
Member

This adds a new connection option trace to control if long stack traces are generated. The default if not specified is to generate them, which keeps the default behavior the same.

This also makes a minor tweak on how the initial stack is generated. Before it was generated in the Sequence constructor, so it captured the stack at the time the protocol sequence was generated. The stack is now captured in Protocol.prototype._enqueue. In all cases within the public API this captures the same stack, except there will be the extra call to _enqueue at the top of the stack. The following case, though, will be positively altered:

var mysql = require('mysql');
var connection = mysql.createConnection(...);

connection.connect();

connection.query('FAIL', function (err) { // 1
  if (err) throw err;
  // Stack trace will include the line marked 1, as expected
});

var query = connection.createQuery('FAIL'); // 2

connection.query(query, function (err) { // 3
  if (err) throw err;
  // Stack trace will include the line marked 3
  // Prior to this it would include the line marked 2
});

The change of the call site capture essentially moves the stack when using require('mysql').createQuery from the call to createQuery to the actual location where the query was handed over to the connection.

closes #710

@sidorares
Copy link
Member

👍

@felixge
Copy link
Collaborator

felixge commented Jan 17, 2014

💖 👍

sidorares added a commit that referenced this pull request Jan 17, 2014
Add trace flag for configuring long stack traces
@sidorares sidorares merged commit 7a10471 into mysqljs:master Jan 17, 2014
@sidorares
Copy link
Member

published as v2.0.1 (could be 2.1 as it's new api, but I think due to defaults it more like patch level bump)

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

Successfully merging this pull request may close these issues.

Use long stack traces only when debug is true
3 participants