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

Unhandled errors do not provide enough information to debug #3257

Closed
6 tasks done
jsakas opened this issue Apr 25, 2023 · 5 comments
Closed
6 tasks done

Unhandled errors do not provide enough information to debug #3257

jsakas opened this issue Apr 25, 2023 · 5 comments

Comments

@jsakas
Copy link

jsakas commented Apr 25, 2023

Describe the bug

We are migrating a large code base from webpack/jest to vite/vitest. Our test suite has about 500 specs, and we are receiving unhandled exceptions in CI only. These unhandled exceptions fail intermittently every 3 - 4 runs. When we ssh into the server and run the same command, they always pass.

The primary issue that we face is that we cannot trace these errors back to an individual test spec.

 Test Files  125 passed | 3 skipped (128)
      Tests  514 passed | 15 skipped (529)
   Start at  21:08:36
   Duration  105.22s (transform 80.64s, setup 488.51s, collect 1846.73s, tests 254.45s, environment 130.44s, prepare 32.53s)

⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯ Uncaught Exception ⎯⎯⎯⎯⎯
ReferenceError: Blob is not defined
 ❯ Response.Body._initBody ../../node_modules/whatwg-fetch/dist/fetch.umd.js:239:34
 ❯ new Response ../../node_modules/whatwg-fetch/dist/fetch.umd.js:462:10
 ❯ Timeout._onTimeout ../../node_modules/whatwg-fetch/dist/fetch.umd.js:529:19
 ❯ listOnTimeout internal/timers.js:557:17
 ❯ processTimers internal/timers.js:500:7

This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
- cancel timeouts using clearTimeout and clearInterval
- wait for promises to resolve using the await keyword
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /home/circleci/.nvm/versions/node/v14.19.3/bin/node
Arguments: /opt/yarn-v1.22.18/lib/cli.js test:unit
Directory: /home/circleci/repo/packages/slate
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.

Exited with code exit status 1

Reproduction

I am not able to provide a reproduction due to private software which is quite large.

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (36) x64 Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz
    Memory: 1.81 GB / 68.58 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 6.14.17 - ~/.nvm/versions/node/v14.19.3/bin/npm
  npmPackages:
    @vitest/coverage-c8: ^0.29.8 => 0.29.8 
    vitest: ^0.30.1 => 0.30.1

Used Package Manager

yarn

Validations

@jsakas
Copy link
Author

jsakas commented Apr 25, 2023

Side note for anyone else who experiences this issue, we are able to get our CI pipeline to pass by using this option in our vitest config:

  test: {
    dangerouslyIgnoreUnhandledErrors: true,
  },

We do not look at this as a long-term solution, but without being able to debug these unhandled exceptions we are using it for now.

@sethmcleod
Copy link

This seems to be the same non-deterministic unhandled rejection experienced by folks here: #1692 (comment)

@AriPerkkio
Copy link
Member

It would be great to add more information to these errors for sure. Without being able to reproduce this issue it's not possible though. We'll need to be able to reproduce the issue to see if it's possible to capture more information.

@OgulcanCelik
Copy link

OgulcanCelik commented Jul 1, 2023

had this while trying to migrate a legacy react codebase to vite. dangerouslyIgnoreUnhandledErrors didn't work. I extended this to debug and exited as soon as the process finds an unhadled exception like this (in a setup file). Since process, vitest exited as soon as it happened I successfully tracked the problem by checking the last test before exit.

process.on("unhandledRejection", (reason) => {
  process.exit(1);
});

I can't code the share to reproduce, but here how it is basically happened.

in a util function, I have an async API call, which is a wrapper. wrapper rejects, but the util function does not catch this error. I call this util function inside a useEffect hook, as

useEffect(() => {
    const getXCards = async () => {
      const cards = await getCards(state);
    getXCards();
  }, [state]);

this is from a nested component where the parent of its parent is running in a snapshot test with react-test-renderer.

Hope it can help to track this issue.

@github-actions
Copy link

github-actions bot commented Jul 3, 2023

Hello @jsakas. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants