TypeError: Cannot redefine property: DoneListHelper

sulliwanesulliwane MaxOrganization: persoProject: chat middlewareMember
edited September 2016 in Help Center

Hello,

Here is my node app:

app.js (require folder1/ice.js and folder2/ice.js)
  folder1/
    ice.js (require Common.js)
    Common.ice
    Common.js
  folder2/
    ice.js (require Common.js)
    Common.ice
    Common.js

Folder1 and Folder2 content is the same. When I start my node app.js requiring folder1/ice.js and folder2/ice.js, I have this error:

TypeError: Cannot redefine property: OrderListHelper
    at Function.defineProperty (native)
    at Object.Slice.defineSequence (/node_modules/ice/src/Ice/ArrayUtil.js:123:12)
    at Common.js:524:11

Here is part of my Common.ice:

struct Order
    {
    string  ordertype;
    };
sequence<Order>          OrderList;

and here is part of my Common.js:

Slice.defineSequence(CM, "OrderListHelper", "CM.Order", false);

If I comment out the Slice.defineSequence(CM, "OrderListHelper", "CM.Order", false); in one of the Common.js, then the error disappear.

Any idea on this one?

Many thanks for your help :)

Comments

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff

    Hi,

    Why do you have two copies of the Common.ice file and end up including the two generated Common.js file? You should instead only have one Common.ice file and a Common.js file that you can include safely multiple times.

    Cheers,
    Benoit.

  • sulliwanesulliwane MaxOrganization: persoProject: chat middlewareMember

    Hi,
    my JS app is connecting to different ICE server, each server using a different version of this Common.ice, so I generate different versions like:

    • Common.v1.js
    • Common.v2.js
    • Common.v3.js

    And import them in different modules of my Node app. But as they are all redefining the same thing, there is an error. The define operation is probably global...is that voluntary design?

    Many thanks!

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff

    Hi,

    That is a limitation of our module system, modules are only defined the first time they appear and then the same module object is then reused, so you end up trying to redefine a property of a module when you include the generated code several times.

Sign In or Register to comment.