[ 
https://issues.apache.org/jira/browse/THRIFT-1840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14737690#comment-14737690
 ] 

Matt Fysh commented on THRIFT-1840:
-----------------------------------

we use 'namespace js global.etc.etc', then require all the clients and 
recursively walk the global.etc object to match clients to theirnamespaces.
In our thrift wrapper library we need access to the namespaces provided in the 
thrift definition and this is the only way to do it. Using global as the first 
part of the namespace also prevents linting errors with JShint, eslint, etc.

> Thrift Generated Code Causes Global Variable Leaks
> --------------------------------------------------
>
>                 Key: THRIFT-1840
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1840
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Compiler
>    Affects Versions: 0.9
>            Reporter: Russell Bradberry
>              Labels: javascript, node
>         Attachments: 0001-THRIFT-1840-fix-for-global-variable-leak.patch, 
> fix_globals.js
>
>
> When compiling for NodeJS, the compiler creates globally scoped variables 
> which is considered a bad practice as it can create unintended consequences. 
> It also causes many testing frameworks to fail.
> the output looks something like this:
> {code}
> User = module.exports.User = function(args) {
> {code}
> when it should be
> {code}
> var User = module.exports.User = function(args) {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to