fix: cleanup cloud function environment (#7085)

* cleanup!

* update comments

* fix: cloudfunctions
This commit is contained in:
Brendan Wong 2023-08-08 15:21:30 -04:00 committed by GitHub
parent 08501234a8
commit 984cf81911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

@ -6,4 +6,14 @@ module.exports = async function globalSetup() {
port: 3000, port: 3000,
launchTimeout: 50000, launchTimeout: 50000,
}) })
// Wait for wrangler to return a request before running tests
for (let i = 0; i < 3; i++) {
const res = await fetch(new Request('http://127.0.0.1:3000/tokens/ethereum/NATIVE'))
if (res.ok) {
return
}
// Set timeout to make sure the server isn't flooded with requests if wrangler is not running
await new Promise((resolve) => setTimeout(resolve, 500 * (i + 1)))
}
throw new Error('Failed to start server')
} }

@ -1,19 +1,13 @@
{ {
"extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true, "baseUrl": "functions",
"composite": false,
"incremental": true, "incremental": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"], "isolatedModules": false,
"moduleResolution": "node", "jsx": "react",
"module": "esnext",
"noEmit": true,
"strict": true,
"target": "ESNext",
"tsBuildInfoFile": "../node_modules/.cache/tsbuildinfo/functions", // avoid clobbering the build tsbuildinfo "tsBuildInfoFile": "../node_modules/.cache/tsbuildinfo/functions", // avoid clobbering the build tsbuildinfo
"types": ["jest", "node", "@cloudflare/workers-types"], "types": ["jest", "node", "@cloudflare/workers-types"],
"jsx": "react",
"skipLibCheck": true,
"baseUrl": "functions"
}, },
"exclude": ["../node_modules", "../src"], "include": ["**/*.ts", ".ts"],
"include": ["**/*.ts"],
} }

@ -18,7 +18,7 @@
"i18n": "yarn i18n:extract --clean && yarn i18n:compile", "i18n": "yarn i18n:extract --clean && yarn i18n:compile",
"prepare": "concurrently \"npm:ajv\" \"npm:contracts\" \"npm:graphql\" \"npm:i18n\"", "prepare": "concurrently \"npm:ajv\" \"npm:contracts\" \"npm:graphql\" \"npm:i18n\"",
"start": "craco start", "start": "craco start",
"start:cloud": "NODE_OPTIONS=--dns-result-order=ipv4first PORT=3001 npx wrangler pages dev --node-compat --proxy=3001 --port=3000 -- yarn start", "start:cloud": "NODE_OPTIONS=--dns-result-order=ipv4first PORT=3001 npx wrangler pages dev --node-compat --compatibility-date=2023-08-04 --proxy=3001 --port=3000 -- yarn start",
"build": "craco build", "build": "craco build",
"analyze": "source-map-explorer 'build/static/js/*.js' --only-mapped", "analyze": "source-map-explorer 'build/static/js/*.js' --only-mapped",
"serve": "serve build -l 3000", "serve": "serve build -l 3000",