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

Add support for node 20 and drop support for node < 18 #2827

Merged
merged 3 commits into from Jan 22, 2024
Merged

Add support for node 20 and drop support for node < 18 #2827

merged 3 commits into from Jan 22, 2024

Conversation

xuesichao
Copy link
Contributor

@xuesichao xuesichao commented Jan 18, 2024

Issue #2825:

Description of changes:
Add support for node 20 and drop support for node < 18

Testing:

Verified npm install works for demos and sdks. Tested meeting demo e2e.

Node 18

=============================== Coverage summary ===============================
Statements   : 100% ( 11908/11908 )
Branches     : 100% ( 5399/5399 )
Functions    : 100% ( 2177/2177 )
Lines        : 100% ( 11730/11730 )
================================================================================

~/Projects/amazon-chime-sdk-js node20* 4m 13s                                                   10:50:49 PM
❯ node -v          
v18.17.1

Node 20

=============================== Coverage summary ===============================
Statements   : 100% ( 11908/11908 )
Branches     : 100% ( 5399/5399 )
Functions    : 100% ( 2177/2177 )
Lines        : 100% ( 11730/11730 )
================================================================================

~/Projects/amazon-chime-sdk-js node20* 4m 16s                                                   10:55:43 PM
❯ node -v          
v20.11.0

Can these tested using a demo application? Please provide reproducible step-by-step instructions.
N/A

Checklist:

  1. Have you successfully run npm run build:release locally?
    Yes, succeeded.

  2. Do you add, modify, or delete public API definitions? If yes, has that been reviewed and approved?
    No

  3. Do you change the wire protocol, e.g. the request method? If yes, has that been reviewed and approved?
    No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@xuesichao xuesichao requested a review from a team as a code owner January 18, 2024 20:17
@xuesichao xuesichao mentioned this pull request Jan 18, 2024
@xuesichao xuesichao force-pushed the node20 branch 2 times, most recently from 5c10d02 to 629b521 Compare January 18, 2024 20:26
* Returns a Crypto object, either from the window or from the node:crypto package.
* @returns Get the crypto object from the global scope.
*/
export function getCrypto(): Crypto {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When running unit tests, it's node env not browser env, we need this to be able to pass the unit test.
Check https://nodejs.org/api/crypto.html#determining-if-crypto-support-is-unavailable

Copy link
Contributor

Choose a reason for hiding this comment

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

We do not support Node enviroment though. In our unit test can we catch the error and just return math.random instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We did mock crypto.getRandomValues() here:

But the problem I'm having now is, when running unit test using node 20, it throws this error:

     TypeError: Cannot set property crypto of #<Object> which has only a getter
      at new DOMMockBuilder (test/dommock/DOMMockBuilder.ts:1525:21)
      at Context.<anonymous> (test/messagingsession/MessagingSessionConfiguration.test.ts:16:22)
      at processImmediate (node:internal/timers:478:21)

I'm trying to resolve this and then we should be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm so maybe we can just check on whether window.crypto exists, log a warning and fall back to Math.random instead? We do not support Node so kinda prefer just fallback to something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@xuesichao xuesichao force-pushed the node20 branch 2 times, most recently from 04d8a6c to 8bb62cf Compare January 22, 2024 08:22
Comment on lines +16 to +17
"webpack": "^5.89.0",
"webpack-cli": "^4.8.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to update the webpack version to avoid this issue:
webpack/webpack#14532

The webpack hashing algorithm uses node:crypto

@ltrung ltrung merged commit 59fe665 into main Jan 22, 2024
10 checks passed
@ltrung ltrung deleted the node20 branch January 22, 2024 16:44
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

Successfully merging this pull request may close these issues.

None yet

3 participants