fix(gpt-runner-cli): fix readable stream polyfill not working in nodejs 18+
This commit is contained in:
@@ -56,17 +56,19 @@ export async function startCli(cwd = PathUtils.resolve(process.cwd()), argv = pr
|
||||
autoFreePort: true,
|
||||
})
|
||||
|
||||
const startServerProcessPromise = execa('node', [startServerJsPath, '--port', String(finalPort)], {
|
||||
env: {
|
||||
...process.env,
|
||||
...getRunServerEnv(),
|
||||
GPTR_ONLY_LOAD_CONFIG_PATH: options.config || '',
|
||||
},
|
||||
})
|
||||
|
||||
startServerProcessPromise.on('error', (error) => {
|
||||
try {
|
||||
await execa('node', [startServerJsPath, '--port', String(finalPort)], {
|
||||
env: {
|
||||
...process.env,
|
||||
...getRunServerEnv(),
|
||||
GPTR_ONLY_LOAD_CONFIG_PATH: options.config || '',
|
||||
},
|
||||
stdio: 'inherit',
|
||||
})?.pipeStdout?.(process.stdout)?.pipeStderr?.(process.stderr)
|
||||
}
|
||||
catch (error) {
|
||||
consola.error(error)
|
||||
})
|
||||
}
|
||||
|
||||
const afterServerStartSuccess = async () => {
|
||||
const getUrl = (isLocalIp = false) => {
|
||||
@@ -101,12 +103,17 @@ export async function startCli(cwd = PathUtils.resolve(process.cwd()), argv = pr
|
||||
}
|
||||
}
|
||||
|
||||
waitPort({
|
||||
port: finalPort,
|
||||
output: 'silent',
|
||||
}).then(afterServerStartSuccess).catch(consola.error)
|
||||
try {
|
||||
await waitPort({
|
||||
port: finalPort,
|
||||
output: 'silent',
|
||||
})
|
||||
|
||||
await startServerProcessPromise
|
||||
afterServerStartSuccess()
|
||||
}
|
||||
catch (error) {
|
||||
consola.error(error)
|
||||
}
|
||||
})
|
||||
|
||||
cli.help()
|
||||
|
||||
@@ -111,8 +111,8 @@
|
||||
"socket.io": "^4.7.2",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"undici": "^5.23.0",
|
||||
"web-streams-polyfill": "^3.2.1",
|
||||
"zod": "^3.21.4",
|
||||
"web-streams-polyfill": "^4.0.0-beta.3",
|
||||
"zod": "^3.22.0",
|
||||
"zod-to-json-schema": "^3.21.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Headers, Request, Response, fetch } from 'undici'
|
||||
import { ReadableStream } from 'web-streams-polyfill'
|
||||
import 'web-streams-polyfill/polyfill'
|
||||
import { canUseNodeFetchWithoutCliFlag } from './check-node-version'
|
||||
|
||||
export function addNodejsPolyfill() {
|
||||
@@ -10,6 +10,5 @@ export function addNodejsPolyfill() {
|
||||
globalThis.Headers = Headers as any
|
||||
globalThis.Request = Request as any
|
||||
globalThis.Response = Response as any
|
||||
globalThis.ReadableStream = ReadableStream as any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"eventemitter": "^0.3.3",
|
||||
"express": "^4.18.2",
|
||||
"framer-motion": "^10.15.1",
|
||||
"framer-motion": "^10.15.2",
|
||||
"fs-extra": "^11.1.1",
|
||||
"global-agent": "^3.0.0",
|
||||
"i18next": "^23.4.4",
|
||||
@@ -130,7 +130,7 @@
|
||||
"vite": "^4.4.9",
|
||||
"vite-plugin-monaco-editor": "^1.1.0",
|
||||
"vite-plugin-svgr": "^3.2.0",
|
||||
"web-streams-polyfill": "^3.2.1",
|
||||
"web-streams-polyfill": "^4.0.0-beta.3",
|
||||
"zustand": "^4.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
38
pnpm-lock.yaml
generated
38
pnpm-lock.yaml
generated
@@ -235,14 +235,14 @@ importers:
|
||||
specifier: ^5.23.0
|
||||
version: 5.23.0
|
||||
web-streams-polyfill:
|
||||
specifier: ^3.2.1
|
||||
version: 3.2.1
|
||||
specifier: ^4.0.0-beta.3
|
||||
version: 4.0.0-beta.3
|
||||
zod:
|
||||
specifier: ^3.21.4
|
||||
version: 3.21.4
|
||||
specifier: ^3.22.0
|
||||
version: 3.22.0
|
||||
zod-to-json-schema:
|
||||
specifier: ^3.21.4
|
||||
version: 3.21.4(zod@3.21.4)
|
||||
version: 3.21.4(zod@3.22.0)
|
||||
devDependencies:
|
||||
'@types/express':
|
||||
specifier: ^4.17.17
|
||||
@@ -377,8 +377,8 @@ importers:
|
||||
specifier: ^4.18.2
|
||||
version: 4.18.2
|
||||
framer-motion:
|
||||
specifier: ^10.15.1
|
||||
version: 10.15.1(react-dom@18.2.0)(react@18.2.0)
|
||||
specifier: ^10.15.2
|
||||
version: 10.15.2(react-dom@18.2.0)(react@18.2.0)
|
||||
fs-extra:
|
||||
specifier: ^11.1.1
|
||||
version: 11.1.1
|
||||
@@ -464,8 +464,8 @@ importers:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0(rollup@3.28.0)(vite@4.4.9)
|
||||
web-streams-polyfill:
|
||||
specifier: ^3.2.1
|
||||
version: 3.2.1
|
||||
specifier: ^4.0.0-beta.3
|
||||
version: 4.0.0-beta.3
|
||||
zustand:
|
||||
specifier: ^4.4.1
|
||||
version: 4.4.1(@types/react@18.2.20)(react@18.2.0)
|
||||
@@ -12321,8 +12321,8 @@ packages:
|
||||
resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==}
|
||||
dev: false
|
||||
|
||||
/framer-motion@10.15.1(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-6avJj/Uftblw0fMmo6jDHkKRH4TBdkMX/FiyR3G/hFe3hQHE4BUNJCqlMPKg9EzfI5jyqDOwO5oDnU+bW5y0eg==}
|
||||
/framer-motion@10.15.2(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-z14GYH4WQXnuTgggwf0qyX0vo98PDE+dw21F7aLzUqEcrsmfLovy4jPiA82Cp/X0juWuEHte7rJGOjds9GAQFA==}
|
||||
peerDependencies:
|
||||
react: ^18.0.0
|
||||
react-dom: ^18.0.0
|
||||
@@ -20452,10 +20452,6 @@ packages:
|
||||
resolution: {integrity: sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==}
|
||||
dev: false
|
||||
|
||||
/web-streams-polyfill@3.2.1:
|
||||
resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
/web-streams-polyfill@4.0.0-beta.3:
|
||||
resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==}
|
||||
engines: {node: '>= 14'}
|
||||
@@ -21132,10 +21128,22 @@ packages:
|
||||
zod: 3.21.4
|
||||
dev: false
|
||||
|
||||
/zod-to-json-schema@3.21.4(zod@3.22.0):
|
||||
resolution: {integrity: sha512-fjUZh4nQ1s6HMccgIeE0VP4QG/YRGPmyjO9sAh890aQKPEk3nqbfUXhMFaC+Dr5KvYBm8BCyvfpZf2jY9aGSsw==}
|
||||
peerDependencies:
|
||||
zod: ^3.21.4
|
||||
dependencies:
|
||||
zod: 3.22.0
|
||||
dev: false
|
||||
|
||||
/zod@3.21.4:
|
||||
resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==}
|
||||
dev: false
|
||||
|
||||
/zod@3.22.0:
|
||||
resolution: {integrity: sha512-y5KZY/ssf5n7hCGDGGtcJO/EBJEm5Pa+QQvFBeyMOtnFYOSflalxIFFvdaYevPhePcmcKC4aTbFkCcXN7D0O8Q==}
|
||||
dev: false
|
||||
|
||||
/zustand@4.4.1(@types/react@18.2.20)(react@18.2.0):
|
||||
resolution: {integrity: sha512-QCPfstAS4EBiTQzlaGP1gmorkh/UL1Leaj2tdj+zZCZ/9bm0WS7sI2wnfD5lpOszFqWJ1DcPnGoY8RDL61uokw==}
|
||||
engines: {node: '>=12.7.0'}
|
||||
|
||||
Reference in New Issue
Block a user