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

Percy agent only handling exit case not error or close #381

Closed
csi-lk opened this issue Oct 1, 2019 · 7 comments
Closed

Percy agent only handling exit case not error or close #381

csi-lk opened this issue Oct 1, 2019 · 7 comments

Comments

@csi-lk
Copy link

csi-lk commented Oct 1, 2019

Hey guys, we're facing an issue with percy-cypress > percy-agent where cypress has posted a code error and exited with an error code of 13, log:

Module not found: Error: Can't resolve 'mocha' in [file]
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

  (Results)

  ┌─────────────────────────────────────┐
  │ Tests:        0                     │
  │ Passing:      0                     │
  │ Failing:      1                     │
  │ Pending:      0                     │
  │ Skipped:      0                     │
  │ Screenshots:  0                     │
  │ Video:        false                 │
  │ Duration:     0 seconds             │
  │ Estimated:    23 seconds            │
  │ Spec Ran:     spec/sname.spec.ts    │
  └─────────────────────────────────────┘

[...]

error Command failed with exit code 13.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[percy] stopping percy...
[percy] waiting for 37 snapshots to complete...
[percy] done.

I don't know for sure but it could be related to Percy only catching exit from spawn, might be worth updating to include error and close as per the node docs too eg.

spawnedProcess.on('error', (code) => this.stop(code))
spawnedProcess.on('close', (code) => this.stop(code))

If not any ideas would be appreciated, cheers

@wwilsman
Copy link
Contributor

wwilsman commented Oct 1, 2019

Hey Callum!

We shouldn't need to handle the close event since the spawned process inherits stdio. But we should definitely handle the error case! Although there is no code when an error is thrown, we can at least log the error and stop the server. I'll have a fix for that out shortly! 👍

I'm not quite sure where your example comes into play though? It looks like the process did successfully exit, and Percy correctly shut down its internal server after finishing up. I verified that the proper exit code is also returned from Percy. What are you expecting to happen in this situation?

@csi-lk
Copy link
Author

csi-lk commented Oct 2, 2019

Hey @wwilsman, expecting percy to exit with an error code it seemed to exit successfully and let the CI progress, hard to say as I don't have a lot of logging for this, i'll do some more digging and see what I can find. Thanks for jumping on the suggested change so quickly 👌

@wwilsman
Copy link
Contributor

wwilsman commented Oct 2, 2019

@csi-lk No problem!

If you echo $? that will give you the exit code of the very last command that was run. I verified that Percy does seem to pass along the exit code properly, but I can't seem to reproduce exit code 13 in Cypress.

Would you mind sharing the command you use to start Percy + Cypress? That might have something to do with this. 🤔

@Robdel12
Copy link
Contributor

Going to close this issue since it's a bit old -- please comment back if this is still an issue!

@MartinKristof
Copy link

Hi, I am not able to resolve it. I run cypress and percy in docker compose, but it returns exti code 0 even if there is failed assertion of cypress test. Could you help me, please?

@Robdel12
Copy link
Contributor

Hey @MartinKristof! @percy/agent is deprecated, I would upgrade to @percy/cli as soon as you can: https://docs.percy.io/docs/migrating-to-percy-cli

@MartinKristof
Copy link

We use percy/cli of course. But still same issue.

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

4 participants