• Time is not a function

    From Kirkman@VERT/GUARDIAN to All on Sat Jan 3 20:16:03 2015
    I have noticed that when I'm working on JS projects for the board, if I do something dumb that crashes the script, sometimes it affects other javascript components on the board.

    For example, say I'm writing a game, and I leave out a curly brace or something. The BBS will throw an error. I'll fix my code, but then later when I go to post a message, SlyEdit crashes on launch with the error "time is not a function."

    I have seen this "time is not a function" many times with other JS parts of the board, like games. It only happens if I did something in my own code that errored out first.

    The only fix is to reboot the machine.

    I'm just wondering: why does this happen? Why should my script's error then later cause other components of the board to not work?

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    þ Synchronet
  • From Digital Man@VERT to Kirkman on Mon Jan 5 03:12:36 2015
    Re: Time is not a function
    By: Kirkman to All on Sat Jan 03 2015 12:16 pm

    I have noticed that when I'm working on JS projects for the board, if I do something dumb that crashes the script, sometimes it affects other javascript components on the board.

    For example, say I'm writing a game, and I leave out a curly brace or something. The BBS will throw an error. I'll fix my code, but then later when I go to post a message, SlyEdit crashes on launch with the error "time is not a function."

    I have seen this "time is not a function" many times with other JS parts of the board, like games. It only happens if I did something in my own code that errored out first.

    How is *your code* being executed? If executed correctly (e.g. via an external configured with a "?script" command-line) the script should execute in its own JS context and not be able to corrupt others.

    time() is a global function (a.k.a. method) in the Synchronet object model, so it is possible that if your script executes in the same context and somehow deletes or overwrites the time() function that could trigger the error, but I don't think that would be normal.

    The only fix is to reboot the machine.

    Really? Just restarting Synchronet should fix any JS context stuff. Or even just logging off and back on again. Or recycling the terminal server. Rebooting
    the entire computer is certainly overkill.

    digital man

    Synchronet "Real Fact" #24:
    The Digital Dynamics company ceased day-to-day opperations in late 1995.
    Norco, CA WX: 59.6øF, 44.0% humidity, 5 mph NNW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Kirkman@VERT/GUARDIAN to Digital Man on Wed Mar 11 17:52:44 2015
    Re: Time is not a function
    By: Digital Man to Kirkman on Sun Jan 04 2015 07:12 pm

    I have noticed that when I'm working on JS projects for the board, if
    I do something dumb that crashes the script, sometimes it affects
    other javascript components on the board.

    For example, say I'm writing a game, and I leave out a curly brace or
    something. The BBS will throw an error. I'll fix my code, but then
    later when I go to post a message, SlyEdit crashes on launch with the
    error "time is not a function."

    time() is a global function (a.k.a. method) in the Synchronet object model, so it is possible that if your script executes in the same context and somehow deletes or overwrites the time() function that could trigger the error, but I don't think that would be normal.

    FWIW, I ran into this again today and tracked it down. I have a series of helper functions that I call from my doors. One of these modifies the Date.prototype to add a method. Inside that, I declared a "time" variable without using "var." This must be where it was colliding with the global function.

    For now I've renamed the variable to "t" and added "var" so it's local. But I'll probably redo all that stuff eventually since it's a bad idea to modify prototypes like that.

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    þ Synchronet