Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using warn within an async function #389

Closed
alexjfno1 opened this issue Oct 9, 2017 · 7 comments
Closed

Error when using warn within an async function #389

alexjfno1 opened this issue Oct 9, 2017 · 7 comments

Comments

@alexjfno1
Copy link

alexjfno1 commented Oct 9, 2017

I have a dangerfile.js which contains:

import { schedule, warn } from "danger";

const asyncFunction = async () { ... };

schedule(async () => {
  await asyncFunction();
  message('You havent formated the code using prettier. Please run npm run format before merging the PR');
});

When I run it though I get the error:

{
  fails: [
    {
      message: "Danger failed to run `dangerfile.js`."
    }
  ],
  warnings: [],
  markdowns: ["## Error Error

Operation not allowed on contextified object.
Error: Operation not allowed on contextified object.
    at Object.setPrototypeOf (/Users/af/NS/simulado/node_modules/vm2/lib/contextify.js:195:11)
    at Function.setPrototypeOf (<anonymous>)
    at Object.runtime.mark (/Users/af/NS/simulado/node_modules/danger/node_modules/regenerator-runtime/runtime.js:134:14)
    at Object.apply (/Users/alexf/NS/simulado/node_modules/vm2/lib/contextify.js:288:34)
    at Object.<anonymous> (/Users/alexf/NOTHS/simulado/dangerfile.js:43:61)
    at NodeVM.run (/Users/alexf/NS/simulado/node_modules/vm2/lib/main.js:426:27)
    at Object.<anonymous> (/Users/af/NS/simulado/node_modules/danger/distribution/runner/DangerfileRunner.js:160:24)
    at step (/Users/af/NS/simulado/node_modules/danger/distribution/runner/DangerfileRunner.js:40:23)
    at Object.next (/Users/af/NS/simulado/node_modules/danger/distribution/runner/DangerfileRunner.js:21:53)
    at fulfilled (/Users/af/NS/simulado/node_modules/danger/distribution/runner/DangerfileRunner.js:12:58)

### Dangerfile

--------------^

  "],
  messages: []
}

Any idea's as to why it's failing?

@orta
Copy link
Member

orta commented Oct 9, 2017

Yes - it's some of the sandboxing I've been trying to clean up with #378 and #373

It's on my TODO, but generally speaking the code generated by using async functions #373 triggers the sandbox in vm2 to fail. I'd rather remove the sandbox completely for the moment.

@orta
Copy link
Member

orta commented Oct 9, 2017

If you can, try move that async code into a plugin and it'll be fine today

@alexjfno1
Copy link
Author

@orta Any idea when it's likely to be fixed?

@orta
Copy link
Member

orta commented Oct 10, 2017

Nope, I work on DangerJS in my spare time, so it's hard to offer any schedule - there's a PR #378, but it's still failing

@orta
Copy link
Member

orta commented Oct 15, 2017

Try see if alpha 20 fixes this 👍

@alexjfno1
Copy link
Author

@orta Great that worked!

I'm not sure if this is related but now when I run it on CircleCI I get Error: Cannot find module 'color-convert'

@alexjfno1
Copy link
Author

It seems Error: Cannot find module 'color-convert' was a random failure. Everything seems to be working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants