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

Synth NodejsFunction: Error: ENOTEMPTY: directory not empty, rmdir #32098

Open
1 task
rupe120 opened this issue Nov 12, 2024 · 2 comments
Open
1 task

Synth NodejsFunction: Error: ENOTEMPTY: directory not empty, rmdir #32098

rupe120 opened this issue Nov 12, 2024 · 2 comments
Assignees
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@rupe120
Copy link

rupe120 commented Nov 12, 2024

Describe the bug

cdk synth fails if a prior synth exists in cdk.out with the error:

Error: ENOTEMPTY: directory not empty, rmdir '\\?\C:\CodeCommit\project\group-document-processing\cdk.out\bundling-temp-dc725a4c4531f07cc12d4a763596738b6f71449ea4146dc0c69217eb5b7c5f27'
    at Object.rmdirSync (node:fs:1219:10)
    at _rmdirSync (node:internal/fs/rimraf:260:21)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1268:10)
    at Object.removeSync (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\node_modules\fs-extra\lib\remove\index.js:11:6)   
    at AssetStaging.stageAsset (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:6427)
    at AssetStaging.stageByBundling (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:5777)      
    at stageThisAsset (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:2728)
    at Cache.obtain (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\core\lib\private\cache.js:1:242)
    at new AssetStaging (C:\CodeCommit\project\group-document-processing\node_modules\aws-cdk-lib\core\lib\asset-staging.js:1:3125) {
  errno: -4051,
  syscall: 'rmdir',
  code: 'ENOTEMPTY',
  path: '\\\\?\\C:\\CodeCommit\\project\\group-document-processing\\cdk.out\\bundling-temp-dc725a4c4531f07cc12d4a763596738b6f71449ea4146dc0c69217eb5b7c5f27'

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

Unknown, I tried prior versions and was not able to find one that worked. This was working for me about a week ago and then suddenly stopped.

Expected Behavior

A successful synth

Current Behavior

See description

Reproduction Steps

I have not had the time to rebuild a project to see if it happens with the lambda definition in a fresh project.

This is the lambda definition though:

    const testGetTextractTextDetectionLambda = new NodejsFunction(this, 'test-get-textract-text-detection',
    {
      codeSigningConfig: props.currentEnvironment.deployEnvironment === "dev" ? undefined : codeSigningConfig,
      functionName:`test-get-textract-text-detection-${props.currentEnvironment.deployEnvironment}`,
      description: `Get Textract text detection`,
      runtime: Runtime.NODEJS_20_X,
      entry: 'lib/lambda-stack.test-get-from-textract-text-detection.ts',
      handler: "lambdaHandler",
      timeout: cdk.Duration.minutes(15),
      tracing: Tracing.ACTIVE,
      insightsVersion: LambdaInsightsVersion.VERSION_1_0_143_0,
      deadLetterQueue: dlQueue,
      deadLetterQueueEnabled: true,
      memorySize: 1024,
      environment: {
        REGION_ID: props.env!.region!,
        SOURCE_BUCKET_PATH: props.currentEnvironment.sourceBucketPrefix,
        DOCUMENT_DATE_ANALYSIS_QUESTION_ALIAS: documentDateAnalysisQuestionAlias,
        DOCUMENT_DATE_ANALYSIS_QUESTION: props.appConfig.documentDateAnalysisQuestion,
        EMPLOYER_NAME_ANALYSIS_QUESTION_ALIAS: employerNameAnalysisQuestionAlias,
        EMPLOYER_NAME_ANALYSIS_QUESTION: props.appConfig.employerNameAnalysisQuestion,
        CHAMBER_OF_COMMERCE_ANALYSIS_QUESTION_ALIAS: chamberOfCommerceAnalysisQuestionAlias,
        CHAMBER_OF_COMMERCE_ANALYSIS_QUESTION: props.appConfig.chamberOfCommerceAnalysisQuestion,
        ENVIRONMENT: props.currentEnvironment.deployEnvironment,
        NODE_ENV: "test"
      }
    });
    sourceBucket.grantReadWrite(testGetTextractTextDetectionLambda);
    testGetTextractTextDetectionLambda.addToRolePolicy(new PolicyStatement(
      { 
        actions: [
          'textract:GetDocumentTextDetection'
        ],
        resources: ['*']
      }
    ));

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.166.0

Framework Version

2.166.0

Node.js Version

v20.10.0

OS

Windows 11 Enterprise 22621.4169

Language

TypeScript

Language Version

4.9.5

Other information

No response

@rupe120 rupe120 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 12, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Nov 12, 2024
@ashishdhingra ashishdhingra self-assigned this Nov 12, 2024
@ashishdhingra ashishdhingra added p2 needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 12, 2024
@khushail
Copy link
Contributor

Hi @rupe120 , thanks for reaching out.

I tried to repro the issue with this minimal code of Lambda node js function and its succeeding with synth as well as deployment. Sharing the details -

Code -

const dlQueue = new sqs.Queue(this, 'dlQueue', {
      queueName: 'dlQueue'
    });

    const testGetTextractTextDetectionLambda = new NodejsFunction(this, 'test-get-textract-text-detection',
    {
      codeSigningConfig: undefined,
      functionName:'test-get-textract-text-detection',
      description: `Get Textract text detection`,
      runtime: Runtime.NODEJS_20_X,
      timeout: cdk.Duration.minutes(15),
      entry: 'lib/index.ts',
      handler: 'index.handler',
      tracing: Tracing.ACTIVE,
      insightsVersion: LambdaInsightsVersion.VERSION_1_0_143_0,
      deadLetterQueue: dlQueue,
      deadLetterQueueEnabled: true,
      memorySize: 1024,
      environment: {
        NODE_ENV: "test"
      }
    });
    const sourceBucket = new s3.Bucket(this, 'sourceBuckettestDeploy', {
      bucketName: 'source-bucket-test-deploy',
      removalPolicy: cdk.RemovalPolicy.DESTROY
    });

    sourceBucket.grantReadWrite(testGetTextractTextDetectionLambda);
    testGetTextractTextDetectionLambda.addToRolePolicy(new PolicyStatement(
      { 
        actions: [
          'textract:GetDocumentTextDetection'
        ],
        resources: ['*']
      }
    ));
    //added these statement after 1st synth
    new cdk.CfnOutput(this, 'testGetTextractTextDetectionLambda', { value: testGetTextractTextDetectionLambda.functionArn });
    new cdk.CfnOutput(this, 'sourceBucket', { value: sourceBucket.bucketName });
  }

the code synthesized successfully and I am able to see the cdk diff as well -
Screenshot 2024-11-12 at 1 22 20 PM

used cdk version - 2.166.0 Node - v20.17.0

As I am not able to repro the scenario, could you please share the minimal self contained code to repro the issue.
Also I would suggest you to check the NodeJS version and CDK version as well.

@khushail khushail assigned khushail and unassigned ashishdhingra Nov 12, 2024
@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-reproduction This issue needs reproduction. labels Nov 12, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p2 package/tools Related to AWS CDK Tools or CLI response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants