Skip to content

(cdk-assets): crypto.randomUUID does not exist in Node 14 #23859

Closed
@blimmer

Description

@blimmer

Describe the bug

After #23677 was merged, our builds started failing. That's because this PR imports the randomUUID method from the Node crypto package, which does not exist on Node 14:

import { randomUUID } from 'crypto';

Expected Behavior

I didn't expect this new build to break our deployments. The README currently specifies that you can use Node 14.15.0 or higher:

* JavaScript, TypeScript ([Node.js ≥ 14.15.0](https://nodejs.org/download/release/latest-v14.x/))

However, Node 14 does not have the randomUUID method:

 /tmp  node
Welcome to Node.js v14.16.0.
Type ".help" for more information.
> const crypto = require('crypto')
undefined
> crypto.randomUUID
undefined

Note that Node 16+ does have that method:

 /tmp  node
Welcome to Node.js v16.14.0.
Type ".help" for more information.
> const crypto = require('crypto')
undefined
> crypto.randomUUID
[Function: randomUUID]

Current Behavior

Our build fails with this error message:

[25%] fail: (0 , import_crypto2.randomUUID) is not a function
[50%] fail: (0 , import_crypto2.randomUUID) is not a function

Reproduction Steps

Publish any CDK zip asset that executes the changes added with this commit: 18e0481

Possible Solution

If Node 14 is no longer supported, the docs should be updated. If Node 14 is still supported, you should polyfill this method.

Additional Information/Context

No response

CDK CLI Version

2.61.1

Framework Version

No response

Node.js Version

14.15.0

OS

Linux

Language

Python

Language Version

No response

Other information

No response

Activity

added
bugThis issue is a bug.
needs-triageThis issue or PR still needs to be triaged.
on Jan 26, 2023
blimmer

blimmer commented on Jan 26, 2023

@blimmer
ContributorAuthor

cc @rscharer, the author of the original PR and @rix0rrr, the approver.

added and removed
needs-triageThis issue or PR still needs to be triaged.
on Jan 31, 2023
added and removed on Feb 3, 2023
added a commit that references this issue on Feb 3, 2023
5bde92c
github-actions

github-actions commented on Feb 3, 2023

@github-actions
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

added a commit that references this issue on Feb 3, 2023
1976f1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p0package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @pahud@blimmer@corymhall

      Issue actions

        (cdk-assets): crypto.randomUUID does not exist in Node 14 · Issue #23859 · aws/aws-cdk