Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Add alert about node vs raven-js when it seems like a browser env #277

Merged
merged 1 commit into from
Feb 23, 2017

Conversation

LewisJEllis
Copy link
Contributor

As per comment here. I do this check in config so that a user can do Raven.disableConsoleAlerts() before Raven.config to avoid seeing this alert.

/cc @benvinegar - does this seem like a reasonable message and condition for "seems like a browser?"

@benvinegar
Copy link
Contributor

Seems reasonable. Is there a way to disable the message? Will people want to, or care?

I think it could be shortened:

This looks like a browser environment. Are you sure you don't want Raven.js (browser JavaScript)?

I might also prefix the output with raven-node: to be clear which library is outputting this.

@LewisJEllis
Copy link
Contributor Author

Is there a way to disable the message?

Yes:

a user can do Raven.disableConsoleAlerts() before Raven.config to avoid seeing this alert.

We already prefix it like "raven@1.1.2: " - could be more clear to do raven-node but then it's not the npm package name, so I explicitly said "Node.js" in the message, but it's probably sufficiently clear anyway. I cleaned up the wording a little more in line with your suggestion.

@LewisJEllis LewisJEllis merged commit 770c8e6 into master Feb 23, 2017
@LewisJEllis LewisJEllis deleted the browser-raven-js-alert branch February 23, 2017 21:38
@shubhamarora
Copy link

shubhamarora commented Feb 28, 2017

@LewisJEllis @benvinegar As per my understanding, this error is coming while bundling.

So let me try to explain a bit more. So when webpack comes into action. It makes a dependency tree and then it resolves and include those dependencies in a bundle (which is called output in terms of webpack). This error is being thrown when webpack is bundling, so due to wrong doing, raven-node is coming onto the dependency tree and webpack tries to resolve and include it in the bundle (which should not happen as raven-node should never be shipped in a bundle to client-side/browser) and it further tries to resolve the dependency (pg) of a dependency (raven-node), where it breaks.

This solution - #254 (comment) works, because this way we are telling webpack to not to look up and resolve the dependency ('pg') (more info here) but unknowingly raven-node might be getting shipped with client side bundle as far as I can think of it. Let me know if I can help in digging this further.

Apart from this, Does typeof window check is not fair enough to check if its browser?

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

Successfully merging this pull request may close these issues.

3 participants