# Error: Tarn: opt.max must be an integer

**URL:** <https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714>\
**Category:** General\
**Created:** [27 March 2020 09:19 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714 "2020-03-27T09:19:31Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 09:19 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/1 "2020-03-27T09:19:31Z")

</div>

Hi  
I get a strange error when using the MSSQL-Node (node-red-contrib-mssql-plus v.0.4.0) with nodeRed (v1.0.3).  
When executing a query, it shows: 'Tarn: opt.max must be an integer \> 0'.

The node worked without problems over the last months. Now, after changing SQL Server settings, the error comes up. Unfortunately going back to the old server doesn't solve the problem neither.

Has anyone got an idea what the error msg is about or how to solve it?

Google didn't help that much...

Kind regards

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 March 2020 11:06 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/2 "2020-03-27T11:06:28Z")

</div>

What is the query being run?  
Also is that the complete error message, nothing else?

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 13:49 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/3 "2020-03-27T13:49:55Z")

</div>

It's a simple insert:

```auto
INSERT INTO mqtt_datablockManagementLog (machine,payload)VALUES ('400023','ONLINE');

```

But the error shows up on all queries, regardless of their type.

I've now also checked the log output of NodeRed:

```auto
27 Mar 14:47:07 - [info] [MSSQL-CN:DataWarehouse] Error connecting to server : 172.23.4.55\GalileoAPS, database : DataWarehouse, port : 1433, user : sa
27 Mar 14:47:07 - [info] [MSSQL:BereinigeLog] Error: Tarn: opt.max must be an integer > 0

```

Don't know where the problem is. When inserting wrong data (Password, Server...) it tells me exactly where the error is.

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [27 March 2020 14:10 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/4 "2020-03-27T14:10:02Z")

</div>

Technicly ( i belive 400023 is opt.max) is a a string , not an integer , could you export your flow and share it with us ?

---

<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:** [27 March 2020 14:19 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/5 "2020-03-27T14:19:52Z")

</div>

As @lizzardguki said, your value `'400023'` is a string  
the error says `opt.max must be an integer > 0`  
I would give it a try sending `400023` instead of `'400023'`

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 14:23 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/6 "2020-03-27T14:23:56Z")

</div>

Thank you so much for your support.

I've reduced the flow to a SSCCE (see below).  
Note that the query is not the one from my previous post, but the error msg remains the same.

```auto
[{"id":"4547bc84.5880d4","type":"tab","label":"Forum","disabled":false,"info":""},{"id":"6b0f29f2.9044d8","type":"inject","z":"4547bc84.5880d4","name":"Jede Stunde","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":true,"onceDelay":"0.5","x":140,"y":60,"wires":[["145f7910.9b8617"]]},{"id":"145f7910.9b8617","type":"function","z":"4547bc84.5880d4","name":"QryDeleteData","func":"var out = \"DELETE FROM [mqtt_datablockManagementLog] \"\nout = out + \" WHERE DATEDIFF(DAY, zeitstempel, getDate()) > 7;\"\nmsg.payload=out;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":60,"wires":[["b4771efb.8dcc4"]]},{"id":"b4771efb.8dcc4","type":"MSSQL","z":"4547bc84.5880d4","mssqlCN":"9deeb56.dd4c3c8","name":"BereinigeLog","query":"","outField":"payload","returnType":"0","throwErrors":"0","x":650,"y":60,"wires":[["866efd5e.07b1d8"]]},{"id":"866efd5e.07b1d8","type":"debug","z":"4547bc84.5880d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":60,"wires":[]},{"id":"9deeb56.dd4c3c8","type":"MSSQL-CN","z":"","tdsVersion":"7_3_A","name":"DataWarehouse","server":"172.23.4.55\\GalileoAPS","port":"1433","encyption":false,"database":"DataWarehouse","useUTC":false,"connectTimeout":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false}]

```

---

<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:** [27 March 2020 14:41 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/7 "2020-03-27T14:41:07Z")

</div>

What is the query you are sending now?

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [27 March 2020 14:48 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/8 "2020-03-27T14:48:37Z")

</div>

my suggestion is to:  
add a function before the mssql node  
and use parseInt(opt.max)

Will be offline while fixing my old car,will catch up after isolation time starts 😃 😕

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 15:07 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/9 "2020-03-27T15:07:40Z")

</div>

The query is:

```auto
DELETE FROM [mqtt_datablockManagementLog] 
WHERE DATEDIFF(DAY, zeitstempel, getDate()) > 7;

```

This time without the probability of strange conversion errors 🙂

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 15:10 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/10 "2020-03-27T15:10:42Z")

</div>

> [@lizzardguki](#):
>
> and use parseInt(opt.max)

Sorry, I don't get it. opt.max is not a variable I am using. I don't know where it comes from 🤔

Can you explain? Especially in the context of the second query where there is nothing that could be converted...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 March 2020 15:26 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/11 "2020-03-27T15:26:11Z")

</div>

I think the link below gives some clues, it is to do with `database __pool__ max` being passed as a string instead of an integer.  
I think you had better raise an issue against the node.  
What version of nodejs are you using (`node -v` will tell you)?

> <https://github.com/knex/knex/issues/2570>
>
> When I run this command:
> $ heroku run "knex-migrator init"
> I get the following error:
> Running knex-migrator init on ⬢ my-app... up, run.6370 (Free)
> \[2018-03-31...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 March 2020 15:35 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/12 "2020-03-27T15:35:47Z")

</div>

Oddly I have been completely unable to find what Tarn is.

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 15:37 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/13 "2020-03-27T15:37:21Z")

</div>

> [@Colin](#):
>
> I think you had better raise an issue against the node.

I did, but no reply there. So I tried it here in the Node Red forum 🙂

> [@Colin](#):
>
> What version of nodejs are you using ( `node -v` will tell you)?

Node v12.14.0

---

<div class="post-metadata">

**Author:** ![pedrossag](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@pedrossag](https://discourse.nodered.org/u/pedrossag)\
**Post date:** [27 March 2020 15:59 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/14 "2020-03-27T15:59:14Z")

</div>

OK, now it gets silly.  
I've just modified the js file of the node and hardcoded the pool size to max = 5 regardless of the node config. Restarted the service and everything worked.

Changed the js back to default. Restarted the service and still working.

Btw. No opt or tarn in js of the node. Must be in underlying functions of node red or node js...

I'll update my post in the node-forum. Maybe they can give some further explanation.

Thank you very much for your support.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 March 2020 16:26 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/15 "2020-03-27T16:26:51Z")

</div>

Yep, definitely silly.  
I think tarn is in the underlying mssql module.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 April 2020 16:26 UTC](https://discourse.nodered.org/t/error-tarn-opt-max-must-be-an-integer/23714/16 "2020-04-10T16:26:56Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
