refactor(runtime): collapse unused setup layers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/util/atomic-write/README.md
|
||||
README.md: 2ff4abb6ac10d8b592ccd2056b4f1f92cc8518b0
|
||||
README.zh.md: 4284d06422564268bb9e31d1a1ed06ab5271e562
|
||||
# pnpm run verify-translation-pairing --write packages/code-runtime/code-runtime-subprocess/README.md
|
||||
README.md: 897112a32fa3e776df756d4caaba97b617c6af9e
|
||||
README.zh.md: d9ab3713640fe955d2b36a8f0674f77686e4791b
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,11 @@
|
||||
/** Typed source for the dependency-free execution-world runner bundle. */
|
||||
|
||||
import { Buffer } from 'node:buffer'
|
||||
import { fork } from 'node:child_process'
|
||||
import { spawn } from 'node:child_process'
|
||||
import type { ChildProcess } from 'node:child_process'
|
||||
import { createInterface } from 'node:readline'
|
||||
import type { Readable } from 'node:stream'
|
||||
import { inspect } from 'node:util'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { Worker, isMainThread, parentPort, workerData } from 'node:worker_threads'
|
||||
import {
|
||||
decodeWorkerJson,
|
||||
@@ -56,6 +55,14 @@ const failureKinds = new Set<FailureKind>([
|
||||
|
||||
let maxFrameBytes = 0
|
||||
|
||||
function runnerSource(): string {
|
||||
const evalIndex = process.execArgv.indexOf('--eval')
|
||||
if (evalIndex < 0) throw new Error('code runtime runner requires its eval source')
|
||||
const source = process.execArgv[evalIndex + 1]
|
||||
if (source === undefined) throw new Error('code runtime runner requires its eval source')
|
||||
return source
|
||||
}
|
||||
|
||||
function recordOf(value: unknown): Record<string, unknown> | undefined {
|
||||
return typeof value === 'object' && value !== null ? value as Record<string, unknown> : undefined
|
||||
}
|
||||
@@ -197,10 +204,9 @@ function runLauncher(): void {
|
||||
const startController = (boot: RuntimeBootData): void => {
|
||||
maxOutputBytes = boot.maxOutputBytes
|
||||
maxFrameBytes = boot.maxFrameBytes
|
||||
controller = fork(fileURLToPath(import.meta.url), [], {
|
||||
controller = spawn(process.execPath, process.execArgv, {
|
||||
env: { DSH_CODE_RUNTIME_CONTROLLER: '1' },
|
||||
detached: false,
|
||||
execArgv: [],
|
||||
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
||||
}) as Controller
|
||||
const current = controller
|
||||
@@ -325,7 +331,8 @@ function runController(): void {
|
||||
return
|
||||
}
|
||||
controllerMaxFrameBytes = boot.maxFrameBytes
|
||||
worker = new Worker(new URL(import.meta.url), {
|
||||
const sourceUrl = new URL(`data:text/javascript;base64,${Buffer.from(runnerSource()).toString('base64')}`)
|
||||
worker = new Worker(sourceUrl, {
|
||||
workerData: boot,
|
||||
env: {},
|
||||
execArgv: [],
|
||||
|
||||
Reference in New Issue
Block a user