-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Log to console what would be sent to the server when raven isn't configured #364
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
Conversation
@@ -1732,8 +1746,9 @@ describe('Raven (public API)', function() { | |||
it('should not throw an error if not configured', function() { | |||
this.sinon.stub(Raven, 'isSetup').returns(false); | |||
this.sinon.stub(window, 'send') | |||
Raven.captureMessage('foo'); | |||
assert.isFalse(window.send.called); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we modify this test then to assert that window.makeRequest
wasn't called? Since that's the changed behavior here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to, but I didn't manage to assert the called state on functions indirectly called by the test (maybe I just don't know the sinon test framework well enough, everytime I tried, functions indirectly called asways assert called called false, whether or now they were called). If someone points me in the right direction, I'm quite willing to make the change.
I mostly like this idea, just not sure I like the implementation. I think there is more value we can get out of this. So we have this undocumented What if we added this Then we can always do a I think there's value in being able to log the data being sent regardless of it being configured or not. Do you have any thoughts on this? |
Also worth noting that |
No objection to using logDebug per see. The problem I do have is having this dependent on Raven.debug. Aside from the documentation issue, setting Raven.debug true will spam the console with errors sent by isSetup(), which is called everywhere. A solution if we don't want to change the output of the rest of the code until the meaning and behaviour of Raven.debug is clearer, I propose to add an override parameter to logDebug that would ignore Raven.debug As for calling it from makeRequest(), there is essentially not a single line in makeRequest we actually want to run when isSetup() is false. That's why I put the check in send(). Now when isSetup() is true: Would that work for you? |
…igured. Helps with local debugging of applications using raven.js Conflicts: src/raven.js
@mattrobenolt Ok, I think I made (or obsoleted) most changes discussed. I don't want to be pushy, but the nature of this patch forced me to rebase 3 times already, with non trivial changes each time, so I'd be most grateful if you could review as quickly as possible. |
@benoitg: Is the root issue here that you would like to debug your usage of |
@benvinegar The scenario is that when developing (think on localhost) applications that use sentry, you have several issues (in order of decreasing importance):
|
Okay, thanks for giving me a better understanding. And I appreciate you taking the time to put together this PR and work through it with us. So, after looking everything over, I kind of agree with @mattrobenolt that this should be enabled by setting So how about this ...
Afterwards, we could encourage users developing locally to always have I can also complete the remaining work to make this happen. Your call. Thoughts? |
@benvinegar Well, honestly I'd prefer that it depend on a different configuration parameter than Raven.debug (Raven.disableUnconfiguredConsoleOutput) whose default would be false. I believe someone without a server configured, and now wanting a console output to be a bit of a corner case for most applications. That being said, your proposal does solve my problem also (setting Raven.debug when server in not configured isn't much of a burden for most people, ASSUMING this time we document Raven.debug), so if you disagree with the above, feel free to go ahead with your original proposal. If you need anything from me, feel free to ask. |
I think my preference is to avoid extra configuration parameters – at least, until we're sure we need it. Right now I'm going to go ahead and make the changes I suggested, but by all means, lets come back to this in the future if it needs additional tweaking. Thanks @benoitg. |
Enabling Raven.debug will log outbound request data (refs #364)
Merged as part of #368 |
@benvinegar Doesn't seem to be working. Still investigating, but at first glance logDebug error in isSetup seems to stop any further processing. |
…, and perhaps should be prohibited by logDebug. Fixes functionnal proble with the merge of getsentry#364
@benoitg I just fired up an example, and it seems to work for me: <script src="../src/raven.js"></script>
<script>
Raven.captureException('test'); // NOTE: Raven not configured
</script> I get this on the console:
Am I missing something? |
@benvinegar it's not working for me in the real world. Maybe an interaction with raven plugins. I only get "Error: Raven has not been configured." Pull request #369 fixes it for me. |
Right. But everything I've read suggests that http://stackoverflow.com/questions/25377115/what-is-the-difference-between-throw-error-and-console-error I'd rather find the true source of the bug, if possible. Are your pages public anywhere? Or can you try to recreate in a limited example? |
It's also worth pointing out that this would have absolutely triggered test failures: it('should log an error message, the first time it is called', function () {
hasJSON = true;
globalServer = undefined;
isSetup();
isSetup();
assert.isTrue(window.logDebug.calledWith('error', 'Error: Raven has not been configured.'))
assert.isTrue(window.logDebug.calledOnce);
}); |
@benvinegar The test above wouldn't have caught it. I DID get the error output. But it inhibited further logging by captureMessage @benvinegar The whole thing is open source (https://github.com/ImaginationForPeople/assembl/) , but making an unreleased version with non-working dependencies is not something I have time to do. So, while I haven't managed to reduce it to a test case that has the same symptoms, here is one that does fail. Different symptoms, but probably the real source of the problem (in any event, a real bug my patch in #369 does not fix anyway): <script src="./dist/raven.js"></script>
<script src="./plugins/console.js"></script>
<script>
Raven.debug = true;
console.error("Something");
Raven.captureException('test'); // NOTE: Raven not configured
</script> It outputs a "Uncaught RangeError: Maximum call stack size exceeded" If you change to Raven.debug = false, the error is "Something" is correctly output from within Raven's plugin/console.js I always wondered if that plugin interacted with logDebug, hence my original use of console.log(). I have no clue why in a bigger app I get different symptoms however. As for the fix, I'd just make logDebug not use levels and use console.log(), which isn't caught by the plugin. |
@benoitg Awesome – I knew there was a deeper issue here. We are going to put together a patch to address this. |
@benoitg So turns out, this is a symptom of the console plugin. Not many people use that, so it doesn't see much attention. :) But the console plugin ultimately is patching native See #370 for the fix. |
Ok, I confirm that #370 fixes the issue, thanks. |
It helps a lot with local debugging of applications using raven.js, and allows developpers to see things captured by captureMessage.
Unite tested, and also improves on previous unit tests making sure that no exceptions are thrown when raven isn't configured.