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

CLI doesn't exit on Node 15+ #124

Closed
tommywalkie opened this issue Jul 2, 2021 · 7 comments
Closed

CLI doesn't exit on Node 15+ #124

tommywalkie opened this issue Jul 2, 2021 · 7 comments

Comments

@tommywalkie
Copy link

Originally encountered this issue on Azure Pipelines while testing a project based on React, UVU, esbuild-register, @testing-library/react and jsdom, using Node 12-14-16.4.0.

I could reproduce it on this uvu-jsdom-node-16-repro repo. In Github Actions logs, tests seem to pass in Node 16.4.0 but it doesn't exit (note that I've set up up a 1-minute timeout).

> uvu -r esbuild-register tests/ -i setup

This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills
Sample.test.tsx
• • •   (3 / 3)

  Total:     3
  Passed:    3
  Skipped:   0
  Duration:  70.64ms

Error: The action has timed out.

A notable difference I've seen during my tests is React displays a warning about requestAnimationFrame and cancelAnimationFrame only on the Node 16.4.0 related test, so I'm not entirely sure this is an UVU/sade or JSDOM or React issue.

@tommywalkie
Copy link
Author

This error seems to happen on Node 15.14.0 too.

@tommywalkie tommywalkie changed the title CLI doesn't exit on Node 16.4.0+ CLI doesn't exit on Node 15+ Jul 2, 2021
@thelinuxlich
Copy link

It's happening to me too on Node 16.8

@thelinuxlich
Copy link

Workaround:

test.after(() => {
  setTimeout(() => {
    process.exit(0)
  }, 500)
}) 

@lukeed
Copy link
Owner

lukeed commented Sep 2, 2021

This almost always means a non-uvu asynchronous task is still running / not terminated properly. uvu (currently) only exits once all suites have completed

@thelinuxlich
Copy link

You are right @lukeed, turns out I wasn't closing my websocket connection on test.after()

@tommywalkie
Copy link
Author

tommywalkie commented Oct 25, 2021

FYI, @thelinuxlich's workaround works but when you get more and more suites to run, you'll need a couple setups (via the before and after hooks) to ensure the process doesn't end before all tests ran. Furthermore, we need to use process.exit without passing any exit code, otherwise it (0) overrides the one that is used during a failing test (1).

import type { Context } from 'uvu';
const queue: Map<string, Context> = new Map();
// Use it with the 'before' hook.
export const registerSuite = (ctx: Context) => { queue.set(ctx.__suite__, ctx) };
// Use it with the 'after' hook.
export const cleanupSuite = (ctx: Context) => {
  setTimeout(() => {
    queue.delete(ctx.__suite__);
    if (queue.size === 0) { process.exit() }
  }, 500);
};

@lukeed
Copy link
Owner

lukeed commented Dec 8, 2021

Closing since this was an issue with the code execution & not uvu directly.

Linking #138 since I may still consider adding a --force-exit option to violently shut everything down once all suites' tests have been executed.

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

3 participants