Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted

hi @m.roszak Michal!

why my QA can restart silently?

Ok if i can see critical errors in log but only facts of restart

 

05-01 12:02:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 12:02:0 warning QUICKAPP2046: use exists hardware_id.

05-01 12:02:0 warning QUICKAPP2046: Starting...

05-01 11:36:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 11:36:0 warning QUICKAPP2046: use exists hardware_id.

05-01 11:36:0 warning QUICKAPP2046: Starting...

05-01 10:11:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 10:11:0 warning QUICKAPP2046: use exists hardware_id.

05-01 10:11:0 warning QUICKAPP2046: Starting...

05-01 8:23:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 8:23:0 warning QUICKAPP2046: use exists hardware_id.

05-01 8:23:0 warning QUICKAPP2046: Starting...

05-01 6:13:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 6:13:0 warning QUICKAPP2046: use exists hardware_id.

05-01 6:13:0 warning QUICKAPP2046: Starting...

05-01 4:23:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 4:23:0 warning QUICKAPP2046: use exists hardware_id.

05-01 4:23:0 warning QUICKAPP2046: Starting...

05-01 2:56:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 2:56:0 warning QUICKAPP2046: use exists hardware_id.

05-01 2:56:0 warning QUICKAPP2046: Starting...

05-01 2:31:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 2:31:0 warning QUICKAPP2046: use exists hardware_id.

05-01 2:31:0 warning QUICKAPP2046: Starting...

05-01 1:12:1 warning QUICKAPP2046: Ring deviceID 2685513 started.

05-01 1:12:0 warning QUICKAPP2046: use exists hardware_id.

Posted (edited)

Do you update some fields (api.put "/devices/ID",{...})) of the QuickApp struct? Besides 'properties' it causes a restart.

Do you update/write/delete a file in the QuickApp with the api? also causes restart.

Edited by jgab
  • Topic Author
  • Posted
    10 minutes ago, jgab said:

    Do you update some fields (api.put "/devices/ID",{...})) of the QuickApp struct? Besides 'properties' it causes a restart.

    Do you update/write/delete a file in the QuickApp with the api? also causes restart.

    Please login or register to see this image.

    /monthly_2022_01/image.png.254a871971c5247e8e06120ae9a422da.png" />

     

    also QA hasn't any additional file(s)

    Please login or register to see this attachment.

     

     

     

    Posted (edited)

    ...so then the question is - what strange things do you do in your QA? ;-)

    It could still be bug in your code followed by a crash and a silent restart - but I haven't seen those in a while. If the QA crashes in the main thread it seems to always report - if it crash in a thread (setTimeout) it's still a silent crash but don't cause QA restart... it seems like.

    Edited by jgab
  • Topic Author
  • Posted (edited)
    7 minutes ago, jgab said:

    ...so then the question is - what strange things do you do in your QA? ;-)

    It could still be bug in your code followed by a crash and a silent restart - but I haven't seen those in a while. If the QA crashes in the main thread it seems to always report - if it crash in a thread (setTimeout) it's still a silent crash but don't cause QA restart... it seems like.

    setTimeout

     setTimeout

      setTimeout

       setTimeout

     

    :) yep. 

    i can rewrite this stairs via events ideology what you preach :) but not sure what it fix the root cause issue.

     

    QA attahced.

    Please login or register to see this attachment.

    Edited by 10der
    Posted (edited)

    Ha!, I managed to create a silent crash in the main thread...

    Please login or register to see this code.

     

    A http success handler that dies inside another http success handler (or error handler) and the other handler then dies - gives me a silent crash and restart. Remove the call to g() or just a single handler, and we get an error message.

     

    So, when the first success handler dies there seems to be no place for the second handler to fail to - and we just get a silent restart 

     

    I guess this can be a fairly common error when people nest their httpcalls do deal with the asynchronous nature of HTTPClient's callbacks.

    It would be easier if they let us use coroutines so we could have a "synchronous" version of

    Please login or register to see this link.

    that would allow users to make sequential request... less errors, less upset home coders, and less complaints to Fibaro...

     

    So, you have a bug in your code and the http code is bad at handle some errors in its success/error handlers....

    Solution wrap your success/error handlers in pcall.

    My fibaroExtra.lua library has a compatible net.HTTPClient that does it for you.

    Edited by jgab
    • Thanks 1
  • Topic Author
  • Posted

    Jan.

    Morning

     

    part#1

    Please login or register to see this attachment.

     

     

    part#2

    Please login or register to see this code.

     

    @jgabJan should i wrap  setTimeout as well?

    Posted

    Eh, lot of stuff going on at the same time there....

    What if you just plop in this replacement of net.HTTPClient and code like before?

    Please login or register to see this code.

     

    Posted (edited)

    So, the solution is for Fibaro to protect the success/error handlers with pcall so that users get reasonable error messages.

    The simplest is just to patch the HTTPClient (and there may be issues with other net.* callback functions)

    It would be more efficient to patch the original net.HTTPClient as there would be no need to copy the ops parameters.

    Please login or register to see this code.

    Running this we get an error message instead of a silent restart.

    Edited by jgab
    Posted

    ...also while we wait for Fibaro to improve their framework we can always collect "patches" like this in a quickapp file we include in our QuickApp projects.

    It's also a good idea to include a patched setTimeout/setInterval to also report errors (they are also silent).

    ...and maybe not update QA properties that don't exists etc etc.

     

    ...or you can use my

    Please login or register to see this link.

    file that implements all this + other "missing" functions for QAs....

     

     

    • Thanks 1
    Posted

    I think I found the MVP for silent restarts

    Please login or register to see this code.

    I would at least expect a

    [08.01.2022] [11:25:01] [ERROR] [QUICKAPP806]: main.lua:3: 

     

    • Thanks 1
    Posted

    It's kind of interesting that 

    Please login or register to see this code.

    which also causes an error (foo not defined) does not create a restart.
  • Topic Author
  • Posted
    41 minutes ago, jgab said:

    It's kind of interesting that 

    Please login or register to see this code.

    which also causes an error (foo not defined) does not create a restart.

    yup! already tested before you public here

    its very strange 

    Posted

    The last one is of course related to the setTimeout doesn't log errors in the called function

    7 minutes ago, 10der said:

    yup! already tested before you public here

    its very strange 

    My current thinking is that it's some luabind errors that slip by.

    setTimeout(error,1) restarts but setTimeout(__fibaroSleep,1) does not

    Nothing in "pure Lua" seems to cause restart.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...