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

**URL:** <https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718>\
**Category:** Share Your Nodes\
**Created:** [30 December 2019 00:16 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718 "2019-12-30T00:16:47Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 January 2020 21:37 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/62 "2020-01-04T21:37:07Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8853240c9aed8c6799d5ce572b450ccf8836a294.png)

To be continued ...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 January 2020 22:00 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/63 "2020-01-04T22:00:04Z")

</div>

> [@BartButenaers](#):
>
> Only weird thing I get - very often - in Firefox is this, after I have pressed the " _Start_ " button:
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8853240c9aed8c6799d5ce572b450ccf8836a294.png)

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bcbc16da115f371893dd4225b3dd86479529ae03.png)

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 **RE** start button: which means the current pseudo terminal will be stopped first.
4. Then a new pseudo terminal will be started
5. Oeps 🤔 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:

```auto
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 ...

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [4 January 2020 22:01 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/64 "2020-01-04T22:01:21Z")

</div>

> [@zenofmud](#):
>
> Yes I can remove and reinstall it at will

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/63d8eb2d97a8f9e2382d2692a967ad12d2696e9e.jpeg)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 January 2020 22:07 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/65 "2020-01-04T22:07:39Z")

</div>

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

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

```

I assume that causes the problem somehow...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 January 2020 23:42 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/66 "2020-01-04T23:42:13Z")

</div>

> [@BartButenaers](#):
>
> Only weird thing I get - very often - in Firefox is this, after I have pressed the " _Start_ " button:
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8853240c9aed8c6799d5ce572b450ccf8836a294.png)

This issue is now fixed on Github.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 January 2020 16:53 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/67 "2020-01-06T16:53:54Z")

</div>

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 🙄  
The following code snippet summarizes what goes wrong:

```auto
<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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/819b58bf23c7a0a242dfde07885f73dc4672e426.gif)

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 !!!!!!!!!!!!

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 January 2020 21:59 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/68 "2020-01-06T21:59:38Z")

</div>

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 !!

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [6 January 2020 22:05 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/69 "2020-01-06T22:05:42Z")

</div>

Working fine here Bart! (@BartButenaers)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [6 January 2020 22:07 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/70 "2020-01-06T22:07:28Z")

</div>

Thanks Garry,  
I'm soooooooooooo glad this issue is solved... 👍 👍 👍

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [6 January 2020 22:32 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/71 "2020-01-06T22:32:07Z")

</div>

> [@BartButenaers](#):
>
> @Paul-Reed: I assume this doesn't solve your (authorisation) issue?

No, still cannot install 🙁 - 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....

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 January 2020 22:32 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/72 "2020-01-06T22:32:57Z")

</div>

I’ll try after dinner

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 January 2020 22:38 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/73 "2020-01-06T22:38:08Z")

</div>

Uninstalled it and re-installed it and it worked fine 1st time 🙂

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [6 January 2020 22:39 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/74 "2020-01-06T22:39:28Z")

</div>

> [@cymplecy](#):
>
> Uninstalled it and re-installed it and it worked fine

In a incognito browser?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 January 2020 22:42 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/75 "2020-01-06T22:42:03Z")

</div>

No - I was replying to Barts post 42m ago

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 January 2020 23:08 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/76 "2020-01-06T23:08:46Z")

</div>

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

Just one question - how do display your directory location?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [6 January 2020 23:10 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/77 "2020-01-06T23:10:13Z")

</div>

> [@zenofmud](#):
>
> how do display your directory location?

directory location??

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 January 2020 23:14 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/78 "2020-01-06T23:14:21Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [6 January 2020 23:18 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/79 "2020-01-06T23:18:56Z")

</div>

Not sure what you mean...?  
 ![npm](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/72cf06bc17a79ae31b9b0aa608833beb7ad8c768.jpeg)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 January 2020 23:27 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/80 "2020-01-06T23:27:14Z")

</div>

Running it on my mac. In xterm I see:

```auto
! 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:

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

```

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [7 January 2020 10:21 UTC](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718/81 "2020-01-07T10:21:09Z")

</div>

> [@BartButenaers](#):
>
> @Paul-Reed: I assume this doesn't solve your (authorisation) issue?

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](https://github.com/bartbutenaers/node-red-contrib-xterm/blob/master/xterm_config.js#L235)

A quick reboot, and both node-RED & xterm now loaded fine with no errors 😀  
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;

> <https://github.com/bartbutenaers/node-red-contrib-xterm/commit/e93daee86162db1731425ed72402bfcddf16a1fd>

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

[Previous page](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718.md?page=3)

[Next page](https://discourse.nodered.org/t/announce-node-red-contrib-xterm-second-beta-sidebar/19718.md?page=5)
