test-runner icon indicating copy to clipboard operation
test-runner copied to clipboard

[Bug] "Jest did not exit one second after test run..." warning happens when image is fetched from a remote source

Open ImTheC opened this issue 2 years ago • 4 comments

Describe the bug

It appears that when I use an image that is fetched from a source, it causes test-storybook to give the following warning:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

Steps to reproduce the behavior

  1. Create a brand new Storybook project using Typescript following the documentation.
  2. Add a new story with the following code:
import { Meta } from '@storybook/react';

export default {
  title: 'Example/Image Test',
} as Meta;

export const WithAnImage = () => <img src="https://place-hold.it/350x150" alt="My CDN placeholder" />;
  1. Run test-storybook
  2. See error

Expected behavior

I expected the tests to complete without giving me this warning.

Screenshots and/or logs

Screen Shot 2022-12-23 at 3 57 33 PM

Environment

  • OS: macOS Monterey 12.5
  • Node.js version: v19.2.0
  • NPM version: 8.19.3
  • Browser (if applicable): Headless browser: chromium
  • Browser version (if applicable): ??
  • Device (if applicable): N/A

Additional context

When I use an image that is located in the public directory, I do not see this warning.

ImTheC avatar Dec 23 '22 22:12 ImTheC

Having the same issue occasionally. I used --eject to get the jest config file and pass it detectOpenHandles: true but that didn't do anything, no extra messages were printed and jest just waits forever.

lopis avatar Dec 30 '22 12:12 lopis

I tried using https://github.com/Raynos/leaked-handles to see if I could debug this further and got the following issue:

tcp handle leaked at one of: 
    at Object.fakeCreateConnection [as createConnection] ([...]/node_modules/leaked-handles/stacks.js:98:21)
    at [...]/node_modules/playwright-core/lib/common/netUtils.js:39:33
    at createSocket ([...]/node_modules/playwright-core/lib/common/netUtils.js:38:10)
    at SocksProxy._handleDirect ([...]/node_modules/playwright-core/lib/common/socksProxy.js:343:55)
tcp stream {
  fd: 67,
  readable: true,
  writable: true,
  address: { address: '192.168.178.20', family: 'IPv4', port: 53972 },
  serverAddr: null
}

This doesn't seem super useful, but i'll continue looking into it...

lopis avatar Jan 03 '23 12:01 lopis

As a temporary solution, running the test-runner with --eject and setting forceExit: true forces jest to exit.

lopis avatar Jan 03 '23 13:01 lopis

I'm with the same problem, but not exactly loaded a image.

luisdelgado avatar Sep 15 '23 19:09 luisdelgado