jest icon indicating copy to clipboard operation
jest copied to clipboard

test: fix worker being killed after being spawned

Open phawxby opened this issue 1 year ago • 2 comments

https://github.com/facebook/jest/pull/13106#issuecomment-1208591622

This adds a test case for the issue described above and can be demonstrated with.

cd e2e/worker-restarting 
node ../../packages/jest-cli/bin/jest.js

phawxby avatar Aug 08 '22 22:08 phawxby

@backmask @SimenB I've found the problem and now I've seen it 🤦

I'm writing some more/better tests to try and catch this in future and should have the PR ready to go in an hour or so

phawxby avatar Aug 09 '22 12:08 phawxby

PR is mostly done and I solved a few other bugs that I found while I was at it. I'm nos just trying to resolve the Windows weirdness that doesn't occur on my Windows machine.

phawxby avatar Aug 10 '22 06:08 phawxby

Source of the problem narrowed down on Windows. The child process appears to be crashing as it's forked but I don't know why just yet. Obviously this is only happening on CI making diagnosis a nightmare

phawxby avatar Aug 10 '22 13:08 phawxby

I finally have a local test case for debugging this. The issue is that sometimes on windows stderr simply does not receive any output from the spawned worker so it fails to detect the out of memory situation. It seems to be somewhat similar to this. https://stackoverflow.com/questions/68296421/stderr-of-child-process-not-received-when-child-process-exits

phawxby avatar Aug 10 '22 17:08 phawxby

FINALLY!!!

phawxby avatar Aug 11 '22 07:08 phawxby

These test failures don't appear to be related to my changes, are they known to be flaky?

phawxby avatar Aug 11 '22 10:08 phawxby

These test failures don't appear to be related to my changes, are they known to be flaky?

Yeah, at times 😞 I restarted the failing builds now

SimenB avatar Aug 11 '22 12:08 SimenB

Hopefully this is the PR done

phawxby avatar Aug 11 '22 12:08 phawxby

https://github.com/facebook/jest/releases/tag/v29.0.0-alpha.5

SimenB avatar Aug 11 '22 13:08 SimenB

@SimenB we're getting closer, tests are running locally in our main project on the alpha release and heap usage is remaining stable. What has me confused is I'm getting a tonne of snapshot failures, not sure if there's beena. chance to how snapshots are encoded between 27 - 29 which is causing it. Investigating now

 PASS   unit  src/common/helpers/context/Site/mapSiteUrlContextData.test.ts (8.602 s, 240 MB heap size)
 PASS   unit  src/common/helpers/support/getFiltersForContent/__tests__/index.test.ts (5.026 s, 228 MB heap size)
 PASS   unit  src/common/helpers/context/Site/SiteContext.test.ts (8.986 s, 253 MB heap size)
 PASS   unit  src/common/helpers/sku/__tests__/getSkuPricing.test.ts (8.824 s, 240 MB heap size)
 PASS   unit  src/common/helpers/tokens/lib/__tests__/traverseTokens.test.ts (7.575 s, 202 MB heap size)
 PASS   unit  src/common/helpers/tokens/xrx/category/__tests__/index.test.ts (7.508 s, 206 MB heap size)
 PASS   unit  src/common/helpers/contentful/__tests__/getContentfulCascade.test.ts (7.459 s, 211 MB heap size)
 PASS   unit  src/common/helpers/support/__tests__/buildSupportDownloadUrl.test.ts (7.689 s, 208 MB heap size)
 PASS   unit  src/common/helpers/sitemap/generators/__tests__/SupportDndProductSitemapGenerator.test.ts (7.701 s, 213 MB heap size)
 PASS   unit  src/common/helpers/product/findRelatedProducts/index.test.ts (16.946 s, 238 MB heap size)
 PASS   unit  src/common/helpers/locale/localeMatch/__tests__/beMatch.test.ts (98 MB heap size)
 PASS   unit  src/common/helpers/locale/localeMatch/__tests__/xeroxMatch.test.ts (109 MB heap size)
 PASS   unit  src/common/helpers/product/__tests__/performProductFooterNavCascade.test.ts (8.692 s, 230 MB heap size)
 PASS   unit  src/common/helpers/sitemap/generators/__tests__/MarketingProductSkuSitemapGenerator.test.ts (233 MB heap size)
 PASS   unit  src/common/helpers/contentful/__tests__/getMasterGlossary.test.ts (8.866 s, 241 MB heap size)
 PASS   unit  src/common/helpers/context/Site/mapSiteHeaderFooterContextData/__tests__/mapSecondaryLink.test.ts (8.78 s, 239 MB heap size)
 PASS   unit  src/common/helpers/url/__tests__/chaseUrl.test.ts (8.204 s, 207 MB heap size)
 PASS   unit  src/common/helpers/support/__tests__/getPagesForProduct.test.ts (8.222 s, 205 MB heap size)
 PASS   unit  src/common/helpers/akamai/__tests__/invalidate.test.ts (105 MB heap size)
 PASS   unit  src/common/helpers/context/Locale/mapEntryToLocaleContext.test.ts (144 MB heap size)
...

Look at that heap usage :D

phawxby avatar Aug 11 '22 14:08 phawxby

Ah, it appears to be this change. https://github.com/facebook/jest/pull/13036

This is looking good but I'd prefer more external validation

phawxby avatar Aug 11 '22 14:08 phawxby

Ah, it appears to be this change. #13036

Yep.

https://jestjs.io/docs/next/upgrading-to-jest29#snapshot-format

SimenB avatar Aug 11 '22 14:08 SimenB

@SimenB I know you were hoping for a stable release last week had I not broken jest, I assume that means a stable release this week instead?

phawxby avatar Aug 15 '22 13:08 phawxby

Yep, that's the plan! Mostly waiting for a resolution on #12856

SimenB avatar Aug 15 '22 14:08 SimenB

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Sep 15 '22 00:09 github-actions[bot]