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

aws-cdk-lib/aws-codepipeline-actions: TextDecoder is not defined (2.87 -> 2.93) #26913

Closed
jedkass opened this issue Aug 28, 2023 · 10 comments
Closed
Labels
aws-cdk-lib Related to the aws-cdk-lib package guidance Question that needs advice or information. p2

Comments

@jedkass
Copy link

jedkass commented Aug 28, 2023

Describe the bug

After upgrading aws-cdk-lib from 2.87 to 2.93, when trying to import { LambdaInvokeAction } from 'aws-cdk-lib/aws-codepipeline-actions';, I get the following exception/stack trace:

ReferenceError: TextDecoder is not defined

      2 | Object.defineProperty(exports, "__esModule", { value: true });
      3 | exports.CodePipelineUtils = void 0;
    > 4 | const aws_codepipeline_actions_1 = require("aws-cdk-lib/aws-codepipeline-actions");
        |                                    ^
      5 | const codePipeline_1 = require("../constants/codePipeline");
      6 | const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
      7 | const aws_iam_1 = require("aws-cdk-lib/aws-iam");

      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/shared.js:1:340)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/index.js:1:171)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.js:1:434)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/index.js:1:649)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/lib/index.js:1:649)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/custom-resources/index.js:1:649)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-events-targets/lib/log-group-resource-policy.js:1:198)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-events-targets/lib/log-group.js:1:304)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-events-targets/lib/index.js:1:1189)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-events-targets/index.js:1:649)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-codepipeline-actions/lib/codecommit/source-action.js:1:336)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-codepipeline-actions/lib/codebuild/build-action.js:1:492)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-codepipeline-actions/lib/index.js:1:887)
      at Object.<anonymous> (../node_modules/aws-cdk-lib/aws-codepipeline-actions/index.js:1:649)
      at Object.<anonymous> (../packages/infrakit/dist/utils/codePipelineUtils.js:4:36)
      at Object.<anonymous> (../packages/infrakit/dist/index.js:50:27)
      at Object.<anonymous> (worker/utils/WorkerIdleStatusEmitter.ts:1:1)
      at Object.<anonymous> (worker/process.ts:26:1)

Expected Behavior

I think this should import with no issues, but not sure if I need to take any additional action on my end as part of this upgrade given the introduction of TextDecoder.

Current Behavior

See above.

Reproduction Steps

I honestly don't have a trivial setup here where I can easily extract an SSCCE so this ticket might die. Apologies in advance. I can give an overview of my setup and maybe that + the stack trace can provide enough of a hint for your expertise.

  • I have a yarn workspace with a package that I use for:
    • CDK utility methods that I've reused across different CDK packages
    • Constants I use in both CDK packages as well as service packages (e.g. metric names to emit and then create a CW alarm for).
  • This problem arises in the service package that imports this shared package — specifically on the line I referenced above: import { LambdaInvokeAction } from 'aws-cdk-lib/aws-codepipeline-actions';

Possible Solution

I've seen old TextDecoder issues on the internet related to Node versions, but I'm on a pretty recent version of Node (18.15.0). This change seemed to introduce the line in question, so I'm guessing it's the source of the issue.

Additional Information/Context

No response

CDK CLI Version

2.93.0

Framework Version

No response

Node.js Version

18.15.0

OS

alpine3.17 (node:18.15.0-alpine3.17 docker image)

Language

Typescript

Language Version

TypeScript 5.1.6

Other information

No response

@jedkass jedkass added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 28, 2023
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Aug 28, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 28, 2023
@khushail khushail self-assigned this Aug 28, 2023
@khushail
Copy link
Contributor

khushail commented Aug 28, 2023

Hi @jedkass , thanks for reaching out.

I tried reproducing the issue with statement import { LambdaInvokeAction } from 'aws-cdk-lib/aws-codepipeline-actions',updating from 2.87 to 2.93 but there was no error. I doubt its anything to do with CDK.

It seems more like a Node issue, could you tell if you are able to use TextDecoder` in your app?

@khushail khushail added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Aug 28, 2023
@oleksii-donoha
Copy link

I'm seeing the same issue in my jest unit tests. 2.92.0 is fine, it came with 2.93.0.

● Test suite failed to run

[2023-08-29T10:13:24.807Z] 

[2023-08-29T10:13:24.807Z]     ReferenceError: TextDecoder is not defined

[2023-08-29T10:13:24.807Z] 

[2023-08-29T10:13:24.807Z]     > 1 | import * as cdk from 'aws-cdk-lib'

[2023-08-29T10:13:24.807Z]         | ^

[2023-08-29T10:13:24.807Z]       2 | import * as ec2 from 'aws-cdk-lib/aws-ec2'

[2023-08-29T10:13:24.807Z]       3 | import * as iam from 'aws-cdk-lib/aws-iam'

[2023-08-29T10:13:24.807Z]       4 | import '../../src/testing/testing'

[2023-08-29T10:13:24.807Z] 

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/shared.js:1:402)

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/index.js:1:233)

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.js:1:496)

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/index.js:1:711)

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/index.js:1:711)

[2023-08-29T10:13:24.807Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/index.js:1:711)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/replica-provider.js:1:312)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/table.js:1:658)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/index.js:1:765)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/index.js:1:711)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/backupable-resources-collector.js:1:217)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/selection.js:1:386)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/plan.js:1:385)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/index.js:1:752)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/index.js:1:711)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (node_modules/aws-cdk-lib/index.js:1:8197)

[2023-08-29T10:13:24.808Z]       at Object.<anonymous> (__tests__/compute/ec2.test.ts:1:1)

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 29, 2023
@khushail
Copy link
Contributor

@jedkass ,it would be helpful if you could share the code snippet to repro this issue.

@rehos
Copy link

rehos commented Aug 31, 2023

@oleksii-donoha in ran into the same issue with jest unit tests. I was using an older version of jest and ts-jest and after updating jest to 29.6.4 and ts-jest to 29.1.1 the reference error disappeared. Hope this helps.

@oleksii-donoha
Copy link

It does seem like updating to jest 29 solves the issue

@jedkass
Copy link
Author

jedkass commented Aug 31, 2023

Ahh I didn't realize I didn't post this in the original issue description, but this exception was also cropping up for me in jest unit tests! Sounds like others have resolved this by updating that. Thanks @rehos and @oleksii-donoha!

@khushail khushail removed their assignment Aug 31, 2023
@stefanfreitag
Copy link
Contributor

Today I was also seeing this issue in a GitHub Action for one of my CDK projects.

ReferenceError: TextDecoder is not defined

    > 1 | import { App } from 'aws-cdk-lib';
        | ^
      2 | import { MyStack } from '../src/main';
      3 |
      4 | test('Snapshot', () => {

      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/shared.js:1:402)
      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/runtime/index.js:1:233)
      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.js:1:496)
      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/index.js:1:711)
      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/lib/index.js:1:711)
      at Object.<anonymous> (node_modules/aws-cdk-lib/custom-resources/index.js:1:711)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/replica-provider.js:1:312)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/table.js:1:658)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/lib/index.js:1:765)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-dynamodb/index.js:1:711)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/backupable-resources-collector.js:1:2[17](https://github.com/stefanfreitag/csv-to-heartbeat-yml/actions/runs/6043832323/job/16401510522#step:4:18))
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/selection.js:1:386)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/plan.js:1:385)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/lib/index.js:1:752)
      at Object.<anonymous> (node_modules/aws-cdk-lib/aws-backup/index.js:1:711)
      at Object.<anonymous> (node_modules/aws-cdk-lib/index.js:1:8[19](https://github.com/stefanfreitag/csv-to-heartbeat-yml/actions/runs/6043832323/job/16401510522#step:4:20)7)
      at Object.<anonymous> (test/main.test.ts:1:1)

The GitHub action takes care of updating dependencies, but does not change the CDK version. This points also into the direction that the issue is unrelated to a CDK version upgrade.

Following the previous comments I updated the version(s) related to Jest

 "jest": "^29",
 ...
  "ts-jest": "^29",

and this resolves the issue for me.

@stec00
Copy link

stec00 commented Sep 8, 2023

Yep, upgrading Jest fixed the same issue for me. In light of that, think this issue can probably be closed.

@khushail khushail added guidance Question that needs advice or information. and removed bug This issue is a bug. labels Sep 8, 2023
@peterwoodworth
Copy link
Contributor

good to hear 👍🏻 thanks for sharing the outcome

@github-actions
Copy link

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-cdk-lib Related to the aws-cdk-lib package guidance Question that needs advice or information. p2
Projects
None yet
Development

No branches or pull requests

7 participants