From 806c9e8c024267edafd112185aed874888a61449 Mon Sep 17 00:00:00 2001 From: ianwremmel <1182361+ianwremmel@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:48:07 -0800 Subject: [PATCH 1/2] fix(tool-stack): force proxy to use localhost/ipv4 --- package-lock.json | 13 ++++++++++++- .../@code-like-a-carpenter/tool-stack/package.json | 1 + .../@code-like-a-carpenter/tool-stack/src/proxy.ts | 12 +++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 39975c9c..c44988bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4642,7 +4642,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz", "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==", - "dev": true, "engines": { "node": ">=14" } @@ -27348,6 +27347,7 @@ "glob": "^10.3.10", "http-proxy": "^1.18.1", "lodash.snakecase": "^4.1.1", + "undici": "^6.6.2", "vhost": "^3.0.2" }, "devDependencies": { @@ -27410,6 +27410,17 @@ "node": ">=10" } }, + "packages/@code-like-a-carpenter/tool-stack/node_modules/undici": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.6.2.tgz", + "integrity": "sha512-vSqvUE5skSxQJ5sztTZ/CdeJb1Wq0Hf44hlYMciqHghvz+K88U0l7D6u1VsndoFgskDcnU+nG3gYmMzJVzd9Qg==", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=18.0" + } + }, "packages/@code-like-a-carpenter/tool-stack/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", diff --git a/packages/@code-like-a-carpenter/tool-stack/package.json b/packages/@code-like-a-carpenter/tool-stack/package.json index 0fd2e222..046dcc20 100644 --- a/packages/@code-like-a-carpenter/tool-stack/package.json +++ b/packages/@code-like-a-carpenter/tool-stack/package.json @@ -33,6 +33,7 @@ "glob": "^10.3.10", "http-proxy": "^1.18.1", "lodash.snakecase": "^4.1.1", + "undici": "^6.6.2", "vhost": "^3.0.2" }, "devDependencies": { diff --git a/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts b/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts index 3bcb2ead..865ab826 100644 --- a/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts +++ b/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts @@ -1,6 +1,7 @@ import express from 'express'; import type Server from 'http-proxy'; import httpProxy from 'http-proxy'; +import {Agent, fetch} from 'undici'; import vhost from 'vhost'; import {assert} from '@code-like-a-carpenter/assert'; @@ -84,7 +85,16 @@ export async function startAllProxies({ stackNames.map(async (stackName) => { try { const result = await fetch( - `http://${stackName}.localhost:${port}/api/v1/ping` + `http://${stackName}.localhost:${port}/api/v1/ping`, + { + dispatcher: new Agent({ + connect: { + lookup: (hostname, options, callback) => { + callback(null, [{address: '127.0.0.1', family: 4}]); + }, + }, + }), + } ); if (!result.ok) { const error = new Error(`Stack ${stackName} is not available`); From e7674d54fbe002e0841b3904c9ab7fe20fb80ce9 Mon Sep 17 00:00:00 2001 From: ianwremmel <1182361+ianwremmel@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:50:01 -0800 Subject: [PATCH 2/2] fix(tool-stack): avoid autoloading aws credentials if already set --- packages/@code-like-a-carpenter/tool-stack/src/stacks.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/@code-like-a-carpenter/tool-stack/src/stacks.ts b/packages/@code-like-a-carpenter/tool-stack/src/stacks.ts index 882859a4..51197b88 100644 --- a/packages/@code-like-a-carpenter/tool-stack/src/stacks.ts +++ b/packages/@code-like-a-carpenter/tool-stack/src/stacks.ts @@ -37,7 +37,8 @@ export async function findEndpoints( } async function getStackUrl(stackName: string): Promise { - if (!process.env.CI) { + // If we aleady have an AWS_SECRET_ACCESS_KEY, don't try to to use autoloading + if (!process.env.CI && !process.env.AWS_SECRET_ACCESS_KEY) { process.env.AWS_REGION = process.env.AWS_REGION ?? 'us-east-1'; process.env.AWS_PROFILE = process.env.AWS_PROFILE ?? 'webstorm_playground'; process.env.AWS_SDK_LOAD_CONFIG = process.env.AWS_SDK_LOAD_CONFIG ?? '1';