• Javascript weirdness

    From deon@VERT/ALTERANT to Digital Man on Wed Apr 20 21:16:08 2022
    Re: Javascript weirdness
    By: Digital Man to deon on Tue Apr 19 2022 10:15 pm

    I'll continue to debug further, but my first suspect is that get_all_msg_headers() method. Thanks for the report,

    No problem - glad you see it too :)

    BTW: Not sure if it is related, but is the result of get_all_msg_headers() supposed to be read-only?

    Originally I was iterating through through that result to update the messages, but I was noticing the following behaviour:

    * call get_all_msg_headers()
    * iterate through each item "for (hdr in hdrs)"
    * set hdr.tag to "foo"
    * pass hdr to put_msg_header();

    But the items were not updating.

    If, for example hdr.tag = "bar", if I had a writeln(hdr.tag) after setting it to "foo", it would report "foo". But if I JSON.stringify(hdr), the result shows that the tags field is still "bar".

    My workaround was to redo a call to "get_msg_header(hdr.number)" and use that result to update and pass back to put_msg_header(), but (IMHO) that is a waste calls (if get_all_msg_headers is not meant to be r/o)... I also tried JSON.parse(JSON.stringify(hdr)) that worked too.

    Not sure if that is related?


    ...ëîåï

    ---
    þ Synchronet þ Alterant | an SBBS in Docker on Pi!
  • From Digital Man@VERT to deon on Thu Apr 21 18:17:40 2022
    Re: Javascript weirdness
    By: deon to Digital Man on Wed Apr 20 2022 09:16 pm

    Re: Javascript weirdness
    By: Digital Man to deon on Tue Apr 19 2022 10:15 pm

    I'll continue to debug further, but my first suspect is that get_all_msg_headers() method. Thanks for the report,

    No problem - glad you see it too :)

    BTW: Not sure if it is related, but is the result of get_all_msg_headers() supposed to be read-only?

    Originally I was iterating through through that result to update the messages, but I was noticing the following behaviour:

    * call get_all_msg_headers()
    * iterate through each item "for (hdr in hdrs)"
    * set hdr.tag to "foo"
    * pass hdr to put_msg_header();

    But the items were not updating.

    If, for example hdr.tag = "bar", if I had a writeln(hdr.tag) after setting it to "foo", it would report "foo". But if I JSON.stringify(hdr), the result shows that the tags field is still "bar".

    My workaround was to redo a call to "get_msg_header(hdr.number)" and use that result to update and pass back to put_msg_header(), but (IMHO) that is a waste calls (if get_all_msg_headers is not meant to be r/o)... I also tried JSON.parse(JSON.stringify(hdr)) that worked too.

    Not sure if that is related?

    No, get_all_msg_headers() is not r/o.

    Does put_msg_header() return false when you try to use it in that manner?

    On the originally reported issue with Tags, I found:
    - the issue still happens when using get_msg_header() instead
    - the issue does not happen on Win32 builds
    - the issue goes away when changing one line in js_msgbase.c, but it's clear
    why

    - LAZY_STRING_TRUNCSP_NULL("tags", p->msg.tags, JSPROP_ENUMERATE);
    + LAZY_STRING_TRUNCSP("tags", p->msg.tags, JSPROP_ENUMERATE);

    still looking into it.
    --
    digital man (rob)

    This Is Spinal Tap quote #14:
    The Boston gig has been cancelled. [Don't] worry, it's not a big college town. Norco, CA WX: 64.3øF, 61.0% humidity, 5 mph S wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From deon@VERT/ALTERANT to Digital Man on Fri Apr 22 22:00:16 2022
    Re: Javascript weirdness
    By: Digital Man to deon on Thu Apr 21 2022 06:17 pm

    Originally I was iterating through through that result to update the messages, but I was noticing the following behaviour:

    * call get_all_msg_headers()
    * iterate through each item "for (hdr in hdrs)"
    * set hdr.tag to "foo"
    * pass hdr to put_msg_header();

    But the items were not updating.

    Does put_msg_header() return false when you try to use it in that manner?

    So I cant reproduce this now. I'll revert my code to use get_all_msg_headers and if I can reproduce it, I'll provide a log and the status returned.


    ...ëîåï

    ---
    þ Synchronet þ Alterant | an SBBS in Docker on Pi!
  • From deon@VERT/ALTERANT to Digital Man on Fri Apr 22 22:21:39 2022
    Re: Javascript weirdness
    By: deon to Digital Man on Fri Apr 22 2022 10:00 pm

    Originally I was iterating through through that result to update the messages, but I was noticing the following behaviour:

    * call get_all_msg_headers()
    * iterate through each item "for (hdr in hdrs)"
    * set hdr.tag to "foo"
    * pass hdr to put_msg_header();

    But the items were not updating.

    Does put_msg_header() return false when you try to use it in that manner?

    So I cant reproduce this now. I'll revert my code to use get_all_msg_headers and if I can reproduce it, I'll provide a log and the
    status returned.

    OK, I got it. It seems to depend on whether I work with the object vs the attribute of it.

    First run, where I echo the object "after" put_msg_header:

    for (var X in msgs)

    X:35
    ORIG:0353 <-- msgs[x]
    CHANGE:0425 <-- msgs[x].tags = '0425'
    <put_msg_header>
    <JSON.stringify(msgs[x])> object:{"tags":"0425","number":38,"to":"deon","subject":"Test Reply","from":"Clearing ...
    STATUS:0 <!-- return from put_msg_header
    AFTER:0425 <-- msgs[x]

    vs echo the object "before" put_msg_header:

    X:35
    ORIG:0353 <!-- msgs[x]
    CHANGE:0389 <!-- msgs[x] = '0389'
    <JSON.stringify(msgs[x])> (Note it has reverted) object:{"tags":"0353","number":38,"offset":0,"to":"deon","from":"Clearing Houz","subject":"Test ...
    <put_msg_header>
    STATUS:0 <!-- result
    AFTER:0353 <!-- no change

    So it seems JSON.stringifying the object reverts its value, that doesnt seem right, but as long as I dont do that I guess I'm OK.


    ...ëîåï

    ---
    þ Synchronet þ Alterant | an SBBS in Docker on Pi!
  • From deon@VERT/ALTERANT to Digital Man on Sat May 7 09:19:40 2022
    Re: Javascript weirdness
    By: Digital Man to deon on Thu Apr 21 2022 06:17 pm

    On the originally reported issue with Tags, I found:
    - the issue still happens when using get_msg_header() instead
    - the issue does not happen on Win32 builds
    - the issue goes away when changing one line in js_msgbase.c, but it's clear
    why

    - LAZY_STRING_TRUNCSP_NULL("tags", p->msg.tags, JSPROP_ENUMERATE);
    + LAZY_STRING_TRUNCSP("tags", p->msg.tags, JSPROP_ENUMERATE);

    still looking into it.

    How did you go, any luck?


    ...ëîåï

    ---
    þ Synchronet þ Alterant | an SBBS in Docker on Pi!
  • From Digital Man@VERT to deon on Fri May 6 23:23:57 2022
    Re: Javascript weirdness
    By: deon to Digital Man on Sat May 07 2022 09:19 am

    Re: Javascript weirdness
    By: Digital Man to deon on Thu Apr 21 2022 06:17 pm

    On the originally reported issue with Tags, I found:
    - the issue still happens when using get_msg_header() instead
    - the issue does not happen on Win32 builds
    - the issue goes away when changing one line in js_msgbase.c, but it's clear
    why

    - LAZY_STRING_TRUNCSP_NULL("tags", p->msg.tags, JSPROP_ENUMERATE); + LAZY_STRING_TRUNCSP("tags", p->msg.tags, JSPROP_ENUMERATE);

    still looking into it.

    How did you go, any luck?

    Nope, it's a weird one.
    --
    digital man (rob)

    Rush quote #41:
    Angels and demons dancing in my head, lunatics and monsters underneath my bed Norco, CA WX: 60.9øF, 82.0% humidity, 0 mph ESE wind, 0.00 inches rain/24hrs ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net