Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. Swifty
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    Swifty

    @Swifty

    1
    Posts
    880
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Swifty Follow

    Posts made by Swifty

    • periodic "TypeError: Cannot redefine property" after switching branch

      It seems that some servers will not re-init code environment properly after a branch change through the screeps script UI.

       

      My guess is that the file-global scopes are re-ran, but previous results are still cached. This means that a call to Object.defineProperty is seen as a duplicate call, even though there is only one instance of this line and only one instance of a call to require() for the file.

      Workaround is to re-upload all code, or make a whitespace change in the UI.

      code snippet:

      proto.creep.js
      Object.defineProperty(Creep.prototype, "debug", { get: function () { return this.memory.debug; }, set: function (x) { this.memory.debug = x; } });

      main.js

      require('proto.creep');

       

      example console error:

      proto.creep:13
      Object.defineProperty(Creep.prototype, "debug", { get: function () { return this.memory.debug; }, set: function (x) { this.memory.debug = x; } });
      ^
      TypeError: Cannot redefine property: debug
      at Function.defineProperty (native)
      at proto.creep:13:8
      at main:2:1
      [11:01:31 AM]
      proto.creep:13
      Object.defineProperty(Creep.prototype, "debug", { get: function () { return this.memory.debug; }, set: function (x) { this.memory.debug = x; } });
      ^
      TypeError: Cannot redefine property: debug
      at Function.defineProperty (native)
      at proto.creep:13:8
      at main:2:1
       
      posted in Technical Issues and Bugs
      Swifty