Handsontable v.14.2.0, an error when calling setDataAtCell

Tags: #<Tag:0x00007efc83205ab8> #<Tag:0x00007efc8320f7e8>

A couple of weeks ago I upgraded Handsontable from version 9.0.2 to 14.2.0.

And there is an error when loading one of tables:

“Uncaught Error: Assertion failed: Expecting an unsigned number.
at t.assert (handsontable.full.min.js:933:148046)
at t.default.obtain (handsontable.full.min.js:933:137787)
at t.default.getMeta (handsontable.full.min.js:933:140173)
at h.getCellMeta (handsontable.full.min.js:933:136264)
at t.default.getCellMeta (handsontable.full.min.js:933:104572)
at t.default. (handsontable.full.min.js:933:175843)
at t.fastCall (handsontable.full.min.js:933:219203)
at g.run (handsontable.full.min.js:964:1742)
at t.default.runHooks (handsontable.full.min.js:933:113769)
at t.default.validateCell (handsontable.full.min.js:933:90513)
t.assert @ handsontable.full.min.js:933
obtain @ handsontable.full.min.js:933
getMeta @ handsontable.full.min.js:933
getCellMeta @ handsontable.full.min.js:933
getCellMeta @ handsontable.full.min.js:933
(anonymous) @ handsontable.full.min.js:933
t.fastCall @ handsontable.full.min.js:933
run @ handsontable.full.min.js:964
runHooks @ handsontable.full.min.js:933
validateCell @ handsontable.full.min.js:933
ie @ handsontable.full.min.js:933
setDataAtCell @ handsontable.full.min.js:933
calcTotal @ VM41:1164
afterLoadData @ VM41:667
(anonymous) @ excelTable.js:693
t.fastCall @ handsontable.full.min.js:933
run @ handsontable.full.min.js:964
runHooks @ handsontable.full.min.js:933
t.replaceData @ handsontable.full.min.js:933
loadData @ handsontable.full.min.js:933
loadData @ excelTable.js:1203
(anonymous) @ excelTable.js:1246
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4”.

In this table in an “afterLoadData” hook a function is called to get a sum of cells in a row and to write the result to a cell for a total value.
To write a result a setDataAtCell method is used:
hot.setDataAtCell(row, column, res, source);

In my case row = 0, column = 32, res = 0, source = undefined.

After a sequence of methods and functions called:
setDataAtCell - ie - validateCell - runHooks - run

we get to fastCall method, where in an “if” statement it was expected to call a certain function with defined arguments:

But instead of another function was called, where the third argument was undefined:

And then the undefined argument was sent to a propToCall method and the error detected.

As I see, the wrong function came from globalBucket, it is a value for “beforeValidate” hook.
In a “run” function a variable “l” (L in lower case) assigned a value from this.globalBucket[“beforeValidate”] and it is that (e,t,r) function:

This error began to appear since version 10.0.0.
With version 9.0.2 there was no error, everything worked.

For me helped a solution to comment a block of code in a (e,t,r) function:

After that no errors appear.

Could you, please, check my way of thinking?
May be, there is another solution?

Hi @saken.turlubekov

Thank you for contacting us. Can you please prepare a code demo with the minimal settings where the issue is still replicable? This way it will be easier to determine what the issue might be. Additionally I would recommend to check our migration guides to see if there’s something that has been changed: https://handsontable.com/docs/javascript-data-grid/migration-from-9.0-to-10.0/

Hi, Adrian.

When considering migration from 9.0.2 to 14.2.0 I looked through all the transitional steps and have made all the necessary changes.
After the error had appeared I made a downgrade to version 11.1, then to 10.0 and determined, that the error starts to appear from version 10.0.
I can’t just stay on version 9, because we encountered an issue and it was fixed in version 11.1.0:

Unfortunately I can’t prepare a demo, because in my application I don’t use a “beforeValidate” hook and don’t call a (e,t,r) function directly.
I only make a call to a setDataAtCell method, passing on correct arguments, the rest is on the Handsontable side.

I see that since version 10.0.0 Handsontable has been using a singleton pattern and see that this solution has an impact on how Handsontable methods work.
May be it is not a good idea to save a function with undetermined arguments in a singleton at some moment and use the same values in another place instead of actual values.

I think I provided enough information about this error, pointed to the place, where it occurs and offered one of the possible solutions.
May be the Handsontable team will suggest more better solution.

Hi @saken.turlubekov

Let me consult this case with my colleague, and I’ll get back to you then.

Hi @saken.turlubekov

After consultation with my colleague we are still not able to determine what is the exact problem here. I’m also not sure If I understand your explanation correctly, as you mentioned that you want to upgrade to v. 14.2.0, but you couldn’t because of a bug that was introduced in 10.0 but was fixed in 11.1.0. I don’t quite understand it.

We will also need to have a code demo to properly check it.

Hi, Adrian.

A reason to upgrade was a bug, that had been fixed in 11.1.0, this version would be enough for me.
But I saw that there were a lot of other bugs fixed in versions released later, so deсided to upgrade to the most actual version, 14.2.

After I encountered the error when calling setDataAtCell, I downgraded to 11.1.0, but it didn’t help.
Then I downgraded to 10.0.0, but even in this version the error with setDataAtCell still appeared.

Can’t provide a demo, because it is a significant amount of job - to investigate at what moment Handsontable saves in a singleton a function with undefined arguments and then to prepare a demo to show the error.
This job will take a lot of time, I don’t have this time because of another tasks.

I created this topic mainly to inform the Handsontable team, that the error was introduced in 10.0.0 and still exists.

For me now it is not urgent, because, thanks the God, I found one of the possible solutions.

May be later your team will find a reason of this error and will fix it in new versions.

Hello.

This problem was fixed in a 14.4.0 version of the Handsontable.

I express my gratitude to the Handsontable team.

1 Like

Hi @saken.turlubekov

Thank you for the update. I’m glad that this issue is now solved.