aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
235 stars 100 forks source link

Make region fetching async - fix ENOBUFS error on syncRequest #549

Closed rbbarad closed 2 months ago

rbbarad commented 2 months ago

Description

Background

When running npm run fullBuild, the build would sometimes fail when attempting to fetch AWS regions with the following error:

> ts-node ./build-scripts/generateResources.ts

Fetching AWS regions
Error: spawnSync /usr/local/bin/node ENOBUFS
    at Object.spawnSync (node:internal/child_process:1119:20)
    at spawnSync (node:child_process:847:24)
    at Object.nodeNC [as fastestFunction] (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/node_modules/sync-rpc/lib/index.js:96:12)
    at sendMessage (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/node_modules/sync-rpc/lib/index.js:118:29)
    at /codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/node_modules/sync-rpc/lib/index.js:159:25
    at Object.request (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/node_modules/sync-request/lib/index.js:28:15)
    at fetchLatestRegions (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/build-scripts/generateResources.ts:37:28)
    at Object.<anonymous> (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/build-scripts/generateResources.ts:211:22)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Module.m._compile (/codebuild/output/src1778635634/src/github.com/aws/aws-toolkit-azure-devops/node_modules/ts-node/src/index.ts:858:23)

Problem

The reason for this error is due to our use of the synchronous syncRequest for making the HTTP fetch request.

Solution

Make region fetching async using axios.get

Testing

Checklist

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.