Skip to content

defineProperties on Promise.prototype gives "invalid descriptor!" #255

@dckc

Description

@dckc

still struggling to port test-marshall.js from SwingSet; now I get:

agoric/SwingSet/node_modules/@agoric/eventual-send/dist/eventual-send.esm.js (57) # Break: (host): invalid descriptor!

https://github.com/Agoric/eventual-send/blob/master/src/index.js#L57

I reduced it to the following. If I run it in node, I get defined: getX as expected. In xs (without the trace definition, and with export default function main) I get main.js (4) # Break: (host): invalid descriptor!.

Perhaps that's by design? Perhaps I should be using preload or Compartments differently to do this sort of thing?

function trace(s) {
  console.log(s);
}

function main() {
  trace('in main\n');

  Object.defineProperties(
    Promise.prototype,
    Object.getOwnPropertyDescriptors({
      getX(key) {
        return 2;
      },
    }),
  );

  trace(`defined: ${String(Object.keys(Promise.prototype))}\n`);
}

main();

cc @erights @michaelfig

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions