[Question] - nodeservices - holding onto state between invokes. #1057

Closed
opened 2025-08-09 17:18:42 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @dazinator on 2/2/2017

Hoping someone can point me in the right direction.

I have a js file with a module export that I am invoking using NodeServices. The file looks like this:

var allFiles = {};

module.exports = {
   
    build: function (callback, requestDto) {

        var typescriptFiles = requestDto.files;
        for (var property in typescriptFiles) {
            if (typescriptFiles.hasOwnProperty(property)) {
                allFiles[property] = typescriptFiles[property];
            }
        }

       var result = {};
       result['Echo'] = allFiles;
       callback(null, result);

    }
};

I invoke like this:


 var nodeScript = _script.Value; // lazy loaded singleton
                    var result = await _nodeServices.InvokeExportAsync<TypeScriptCompileResult>(nodeScript.FileName, "build", requestDto);

// result.Echo now contains JObject.

I am trying to persist state in the allFiles object.
However, what I am seeing is that between Invokes, my state is being lost on the node side - i.e allFIles doesn't keep the files I sent it previously with the previous invoke.

What am I missing here?

*Originally created by @dazinator on 2/2/2017* Hoping someone can point me in the right direction. I have a `js` file with a module export that I am invoking using NodeServices. The file looks like this: ```js var allFiles = {}; module.exports = { build: function (callback, requestDto) { var typescriptFiles = requestDto.files; for (var property in typescriptFiles) { if (typescriptFiles.hasOwnProperty(property)) { allFiles[property] = typescriptFiles[property]; } } var result = {}; result['Echo'] = allFiles; callback(null, result); } }; ``` I invoke like this: ```csharp var nodeScript = _script.Value; // lazy loaded singleton var result = await _nodeServices.InvokeExportAsync<TypeScriptCompileResult>(nodeScript.FileName, "build", requestDto); // result.Echo now contains JObject. ``` I am trying to persist state in the allFiles object. However, what I am seeing is that between Invokes, my state is being lost on the node side - i.e `allFIles` doesn't keep the files I sent it previously with the previous invoke. What am I missing here?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1057
No description provided.