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

Russell Bradberry commented on THRIFT-1840:
-------------------------------------------

ah, sorry. I couldn't get the tests to run on my local so I tried my best shot. 
 I think the culprit is the second out << "var ", mayeb it should look more 
like this:

{code}
  if (gen_node_) {
    if (is_exported) {
      out << "var " << js_namespace(tstruct->get_program()) << 
tstruct->get_name() << " = " <<
        "module.exports." << tstruct->get_name() << " = function(args) {\n";
    } else {
      out << js_namespace(tstruct->get_program()) << tstruct->get_name() << " = 
function(args) {\n";
    }
  } else {
    out << js_namespace(tstruct->get_program()) << tstruct->get_name() <<" = 
function(args) {\n";
  }
{code}
                
> 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
>
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to