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

update node.js version for CI to 16 #23243

Closed
wants to merge 2 commits into from
Closed

update node.js version for CI to 16 #23243

wants to merge 2 commits into from

Conversation

sunderls
Copy link
Contributor

@sunderls sunderls commented Feb 7, 2022

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?

> yarn prettier
> yarn lint
> yarn flow
> yarn test
> yarn test --prod

@@ -2,7 +2,7 @@ version: 2.1

aliases:
- &docker
- image: cimg/openjdk:17.0.0-node
- image: cimg/openjdk:17.0.2-node
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2022-02-06 at 22 08 17

});
} catch (e) {
// suppress ERR_UNHANDLED_REJECTION
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before

Screenshot 2022-02-07 at 19 43 56

from CI
Screenshot 2022-02-07 at 20 08 51

after

Screenshot 2022-02-07 at 19 48 13

Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. in act() an error is throw for prod which causes the rejection https://github.com/facebook/react/blob/main/packages/react/src/ReactAct.js#L153

  2. 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?

Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got you!

Copy link
Contributor Author

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);
        });
    })();
  }

Copy link
Collaborator

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?

Copy link
Contributor Author

@sunderls sunderls Feb 7, 2022

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.

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

const maybePromise = callback();

and the exception is not caught, trouble occurs.

since the assertions for this test are under __DEV__

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?

Copy link
Collaborator

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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before

Screenshot 2022-02-06 at 22 07 17

TypeError message is changed from node.js 16

@gaearon
Copy link
Collaborator

gaearon commented Feb 7, 2022

Do we understand why it failed on main but not on PR CI previously? What was the difference?

@sunderls sunderls marked this pull request as draft February 7, 2022 21:55
@sunderls
Copy link
Contributor Author

sunderls commented Feb 7, 2022

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

Screenshot 2022-02-07 at 22 25 38

I couldn't figure out the possible cause on node.js version. since all tests pass for my local env.

Screenshot 2022-02-07 at 22 26 47

I guess the failure is transient , or we can just fix in another chance?

@lunaruan do you know what might be the cause?

@sunderls sunderls marked this pull request as ready for review February 7, 2022 22:30
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants