[ANNOUNCE]node-red-contrib-xterm : second beta (sidebar)

It is my of of "hard to troubleshoot" issues...
Now I cannot reproduce the problem anymore in Firefox.
Only weird thing I get - very often - in Firefox is this, after I have pressed the "Start" button:

image

To be continued ...

Ok found the root cause of the pseudo terminal unexpected stopping, after adding extra logging:

image

  1. I pressed the "Start" button
  2. An ajax request is send to the server
  3. [Optional] Since a pseudo terminal was already running, the button will act as a REstart button: which means the current pseudo terminal will be stopped first.
  4. Then a new pseudo terminal will be started
  5. Oeps :thinking: the pseudo terminal will be stopped again.

The problem is step 5, because I don't want that to happen. The problem is caused in a code snippet that I had added at the end of the beta phase:

ptyProcess.on('exit', function(c) {
   if (xtermProcessInfoMap.has(terminalId)) {
      stopTerminal(terminalId, "exit command", loggingEnabled);
   }
});

I had added that because a user can type the "exit" command in his terminal window. Then the pseudo terminal was stopped without me knowing, resulting in strange behaviour. But I arrive here also due to step 3, but a bit too late because meanwhile the terminal has already been started again in step 4. So he will stop it again. Grrr. Will try to fix that.

But then I still cannot reproduce the tabsheet closing itself ...

Unfortunately, I can't. When I reinstall the xterm node, my flows do not load and I just get the 'loading' gif.

In the browser console, I get this error;

error1

Paul,
Based on the above discussion I have added permissions two days ago to my code:

RED.httpAdmin.get('/xterm_shell/:terminal_id/:command/:info', RED.auth.needsPermission('xterm.write'), function(req, res) {

I assume that causes the problem somehow...

1 Like

This issue is now fixed on Github.

Have been removed part by part, and tested over and over again...
This must be my most time consuming bug in Node-RED until now :roll_eyes:
The following code snippet summarizes what goes wrong:

<script type="text/javascript">   
    (function ($) {
        var globalTerminalConfigNode = null;
        ...
       
        RED.nodes.registerType('xterm_config', {
            ...
            onpaletteadd: function () {
                ...
                // HANDLE THE "START" BUTTON CLICKED EVENT
                $("#node-start-terminal").on("click", function (e) {
                    // IN THE NEXT LINE THE FLOW EDITOR REFRESHES
                    if (globalTerminalConfigNode === null) {
                        ...
                    }
                    ...
                });
            }
        });
    })(jQuery);
</script>

So as soon as the globalTerminalConfigNode variable is being read, the flow editor will start refreshing:

xterm_loading

P.S. if the config node has been created behind the scenes, you will get a popup window whether you want to leave the screen (because the flow editor is being refreshed).

I assume it has something to do with the function ($), but I'm not sure how it works. I copied that line from one of the existing palette tabsheet Github repositories ...

I would really appreciate if somebody could tell me what is wrong in the above code snippet!!!!

THANKS IN ADVANCE !!!!!!!!!!!!

Hey guys (@zenofmud, @ghayne, @cymplecy),
I 'think' I have finally found the error. Was already considering of abandoning this node, since it is taking too much of my free time ...

Seems that html buttons have by default type "submit", so I have used now type "button". After I fixed that, now I cannot reproduce the error anymore. Weird that I didn't have the same problem in my other nodes...

Anyway could you please install the fix from Github, and let me know if it is solved. Fingers crossed...

@Paul-Reed: I assume this doesn't solve your (authorisation) issue?

Thanks !!

1 Like

Working fine here Bart! (@BartButenaers)

Thanks Garry,
I'm soooooooooooo glad this issue is solved... :+1: :+1: :+1:

1 Like

No, still cannot install :slightly_frowning_face: - same issue as described above.
It would be interesting to see if Paul @zenofmud can still load NR in a incognito browser, where auth may not be cached....

Iā€™ll try after dinner

1 Like

Uninstalled it and re-installed it and it worked fine 1st time :slight_smile:

1 Like

In a incognito browser?

No - I was replying to Barts post 42m ago

1 Like

Works for me too :tada: in Safari, Chrome, and chrome incognito mode!

Just one question - how do display your directory location?

directory location??

you know if you enter cd .node-red have it show up in the prompt. I'm sure it is a bash thing...now that I think of it, something in the back of my brain says I should go google it...

Not sure what you mean...?
npm

Running it on my mac. In xterm I see:

! Pseudoterminal has been started (pid=3001 rows=60 cols=120)
bash-3.2$ pwd
/Users/Paul/.node-red
bash-3.2$ 

but in a terminal window I see:

Last login: Mon Jan  6 18:16:29 on ttys000
Pauls-mini-4:~ Paul$ pwd
/Users/Paul
Pauls-mini-4:~ Paul$ 

No, but I again installed the node this morning, and got exactly the same error, so.... I manually edited the xterm_config.js file, removing RED.auth.needsPermission('xterm.write'), from node-red-contrib-xterm/xterm_config.js at master Ā· bartbutenaers/node-red-contrib-xterm Ā· GitHub

A quick reboot, and both node-RED & xterm now loaded fine with no errors :grinning:
Also, as others have reported, xterm now opens smoothly, with no 'flow reloading' issues.

I'm sure you'll be aware that the auth request was introduced by this commit;

PS - I did try editing it to RED.auth.needsPermission('xterm.read'), but that didn't work either!