-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
update node.js version for CI to 16 #23243
Conversation
@@ -2,7 +2,7 @@ version: 2.1 | |||
|
|||
aliases: | |||
- &docker | |||
- image: cimg/openjdk:17.0.0-node | |||
- image: cimg/openjdk:17.0.2-node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}); | ||
} catch (e) { | ||
// suppress ERR_UNHANDLED_REJECTION | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catch-all is risky. How can we narrow it down? Also, why is it needed now exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
in
act()
an error is throw forprod
which causes the rejection https://github.com/facebook/react/blob/main/packages/react/src/ReactAct.js#L153 -
in node.js 15 default behavior for uncaught promise reject was changed from warn to throw, which causes the trouble.
process: Change default --unhandled-rejections=throw nodejs/node#33021. but previously we are using node.js 14, so not an issue.
I guess this fix is fine ? since it should not throw for DEV, do you suggest any other possible fix directions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we catch that specific error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(async () => {
try {
await act(async () => {
await sleep(50);
});
} catch (e) {
// suppress ERR_UNHANDLED_REJECTION from act()
if (e.message !== 'act(...) is not supported in production builds of React.') {
throw e
}
}
})();
this works, or we just guard it with __DEV__
?
if (__DEV__) {
(async () => {
await act(async () => {
await sleep(50);
});
})();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. there is // @gate __DEV__
above. shouldn't this be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, things becoming interesting.
// @gate __DEV__
doesn't skip test in non-Dev, it still runs the test but expects it to fail.
react/scripts/jest/setupTests.js
Lines 270 to 287 in cd4eb11
global._test_gate = (gateFn, testName, callback) => { | |
let shouldPass; | |
try { | |
const flags = getTestFlags(); | |
shouldPass = gateFn(flags); | |
} catch (e) { | |
test(testName, () => { | |
throw e; | |
}); | |
return; | |
} | |
if (shouldPass) { | |
test(testName, callback); | |
} else { | |
test(`[GATED, SHOULD FAIL] ${testName}`, () => | |
expectTestToFail(callback, gatedErrorMessage)); | |
} | |
}; |
The test is still run
react/scripts/jest/setupTests.js
Line 249 in cd4eb11
const maybePromise = callback(); |
and the exception is not caught, trouble occurs.
since the assertions for this test are under __DEV__
react/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
Lines 516 to 525 in cd4eb11
if (__DEV__) { | |
expect(console.error).toHaveBeenCalledTimes(2); | |
expect(console.error.calls.argsFor(0)[0]).toMatch( | |
'You seem to have overlapping act() calls', | |
); | |
expect(console.error.calls.argsFor(1)[0]).toMatch( | |
'You seem to have overlapping act() calls', | |
); | |
} | |
}); |
, I guess we can just use __DEV__
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds reasonable
@@ -899,7 +899,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { | |||
store.set({}); | |||
}); | |||
expect(container.textContent).toEqual( | |||
"Cannot read property 'toUpperCase' of undefined", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we understand why it failed on main but not on PR CI previously? What was the difference? |
There is one mysterious failure on devtool e2e test https://app.circleci.com/pipelines/github/facebook/react/23442/workflows/2d3aa996-abb7-48c7-a8f7-256657b8b1bd/jobs/431345 I couldn't figure out the possible cause on node.js version. since all tests pass for my local env. I guess the failure is transient , or we can just fix in another chance? @lunaruan do you know what might be the cause? |
Summary
PR again for #23236 (one test fix missed for prev PR)
this diff bumps node.js version used CI to 16 to improve the developer experience.
Accordingly some tests needs to be modified.
How did you test this change?