orez 0.2.27 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cf-do/worker.d.ts +3 -0
- package/dist/cf-do/worker.d.ts.map +1 -1
- package/dist/cf-do/worker.js +37 -15
- package/dist/cf-do/worker.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/src/admin/admin-data.test.ts +0 -348
- package/src/admin/http-proxy.ts +0 -252
- package/src/admin/log-store.ts +0 -192
- package/src/admin/server.ts +0 -471
- package/src/admin/ui.ts +0 -1322
- package/src/bench/proxy-throughput.bench.ts +0 -343
- package/src/bench/serial-mutations.bench.ts +0 -270
- package/src/browser.ts +0 -203
- package/src/cf-do/.wrangler/cache/cf.json +0 -1
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/0ffaabee41a60e04dd0eb7db3073f0a40139e6a97ccd26823967acb652b89a7b.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-shm +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-wal +0 -0
- package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-insertion-facade.js +0 -11
- package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-loader.entry.ts +0 -134
- package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-insertion-facade.js +0 -11
- package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-loader.entry.ts +0 -134
- package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js +0 -1059
- package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js.map +0 -8
- package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js +0 -1059
- package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js.map +0 -8
- package/src/cf-do/ARCHITECTURE.md +0 -93
- package/src/cf-do/CHAT_E2E.md +0 -213
- package/src/cf-do/watermark.test.ts +0 -103
- package/src/cf-do/watermark.ts +0 -118
- package/src/cf-do/worker.ts +0 -1041
- package/src/cf-do/wrangler.toml +0 -11
- package/src/cf-pglite/README.md +0 -19
- package/src/change-tracking.ts +0 -25
- package/src/child-process.test.ts +0 -147
- package/src/child-process.ts +0 -90
- package/src/cli-entry.ts +0 -72
- package/src/cli.test.ts +0 -40
- package/src/cli.ts +0 -1214
- package/src/config.ts +0 -150
- package/src/do-sql-tracking.test.ts +0 -19
- package/src/do-sql-tracking.ts +0 -19
- package/src/index.ts +0 -1215
- package/src/integration/integration.test.ts +0 -517
- package/src/integration/native-binary.guard.test.ts +0 -13
- package/src/integration/native-startup.test.ts +0 -44
- package/src/integration/replication-latency.test.ts +0 -428
- package/src/integration/restore-live-stress.test.ts +0 -433
- package/src/integration/restore-reset.test.ts +0 -400
- package/src/integration/restore.test.ts +0 -274
- package/src/integration/test-permissions.ts +0 -147
- package/src/load-config.ts +0 -46
- package/src/log.ts +0 -96
- package/src/mutex.ts +0 -47
- package/src/pg-proxy-browser.singledb.test.ts +0 -233
- package/src/pg-proxy-browser.ts +0 -2022
- package/src/pg-proxy-do-backend.test.ts +0 -3890
- package/src/pg-proxy-do-backend.ts +0 -7191
- package/src/pg-proxy.ts +0 -1087
- package/src/pg-sqlite-compiler/README.md +0 -53
- package/src/pg-sqlite-compiler/catalog/seed.ts +0 -524
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/arithmetic.json +0 -307
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/array.json +0 -377
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/cast.json +0 -12
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/catalog.json +0 -447
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/create-table.json +0 -32
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/datetime.json +0 -397
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/enum.json +0 -337
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/insert.json +0 -337
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/json.json +0 -537
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/misc.json +0 -1837
- package/src/pg-sqlite-compiler/index.ts +0 -73
- package/src/pg-sqlite-compiler/integration.test.ts +0 -136
- package/src/pg-sqlite-compiler/passes/ast-utils.ts +0 -113
- package/src/pg-sqlite-compiler/passes/catalog.ts +0 -65
- package/src/pg-sqlite-compiler/passes/datetime.ts +0 -74
- package/src/pg-sqlite-compiler/passes/index.ts +0 -49
- package/src/pg-sqlite-compiler/passes/types.ts +0 -156
- package/src/pg-sqlite-compiler/smoke.test.ts +0 -69
- package/src/pg-sqlite-compiler/test/catalog.test.ts +0 -171
- package/src/pg-sqlite-compiler/test/corpus.test.ts +0 -161
- package/src/pg-sqlite-compiler/test/datetime.oracle.test.ts +0 -102
- package/src/pg-sqlite-compiler/test/oracle.ts +0 -237
- package/src/pg-sqlite-compiler/test/types.test.ts +0 -109
- package/src/pg-sqlite-compiler/types.ts +0 -63
- package/src/pglite-ipc.test.ts +0 -116
- package/src/pglite-ipc.ts +0 -266
- package/src/pglite-manager.ts +0 -557
- package/src/pglite-web-proxy.test.ts +0 -57
- package/src/pglite-web-proxy.ts +0 -221
- package/src/pglite-web-worker.ts +0 -152
- package/src/pglite-worker-thread.ts +0 -253
- package/src/port.ts +0 -25
- package/src/process-title.ts +0 -9
- package/src/recovery.ts +0 -155
- package/src/replication/change-tracker.test.ts +0 -357
- package/src/replication/change-tracker.ts +0 -279
- package/src/replication/handler.test.ts +0 -511
- package/src/replication/handler.ts +0 -1190
- package/src/replication/pgoutput-encoder.test.ts +0 -697
- package/src/replication/pgoutput-encoder.ts +0 -373
- package/src/replication/tcp-replication.test.ts +0 -876
- package/src/replication/zero-compat.test.ts +0 -1150
- package/src/restore-stress.test.ts +0 -188
- package/src/s3-local.ts +0 -203
- package/src/shim/hooks.mjs +0 -120
- package/src/shim/register.mjs +0 -4
- package/src/sqlite-mode/apply-mode.ts +0 -224
- package/src/sqlite-mode/index.ts +0 -15
- package/src/sqlite-mode/native-binary.ts +0 -89
- package/src/sqlite-mode/package-resolve.ts +0 -17
- package/src/sqlite-mode/resolve-mode.ts +0 -80
- package/src/sqlite-mode/shim-template.ts +0 -159
- package/src/sqlite-mode/sqlite-mode.test.ts +0 -427
- package/src/sqlite-mode/types.ts +0 -30
- package/src/vite-plugin.ts +0 -67
- package/src/wasm-sqlite.test.ts +0 -537
- package/src/worker/browser-admin.ts +0 -52
- package/src/worker/browser-build-config.test.ts +0 -71
- package/src/worker/browser-build-config.ts +0 -109
- package/src/worker/browser-embed-admin.test.ts +0 -75
- package/src/worker/browser-embed.ts +0 -345
- package/src/worker/cf-patches.ts +0 -384
- package/src/worker/embed-integration.test.ts +0 -321
- package/src/worker/index.ts +0 -138
- package/src/worker/shims/fastify.test.ts +0 -255
- package/src/worker/shims/fastify.ts +0 -306
- package/src/worker/shims/http-service.test.ts +0 -355
- package/src/worker/shims/http-service.ts +0 -293
- package/src/worker/shims/node-stub.ts +0 -290
- package/src/worker/shims/oxfmt.ts +0 -3
- package/src/worker/shims/postgres-browser.ts +0 -59
- package/src/worker/shims/postgres-socket.test.ts +0 -576
- package/src/worker/shims/postgres-socket.ts +0 -310
- package/src/worker/shims/postgres.test.ts +0 -364
- package/src/worker/shims/postgres.ts +0 -1454
- package/src/worker/shims/sqlite-browser.test.ts +0 -233
- package/src/worker/shims/sqlite-browser.ts +0 -175
- package/src/worker/shims/sqlite.test.ts +0 -786
- package/src/worker/shims/sqlite.ts +0 -978
- package/src/worker/shims/stream-browser.ts +0 -15
- package/src/worker/shims/ws-browser.test.ts +0 -205
- package/src/worker/shims/ws-browser.ts +0 -248
- package/src/worker/shims/ws.test.ts +0 -288
- package/src/worker/shims/ws.ts +0 -467
- package/src/worker/shims/zero-process-env.ts +0 -11
- package/src/worker/types.ts +0 -75
- package/src/worker/worker-integration.test.ts +0 -223
- package/src/worker/worker.test.ts +0 -136
- package/src/worker/zero-cache-embed-cf.ts +0 -463
- package/src/worker/zero-cache-embed.ts +0 -277
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* zero-cache embedded runner.
|
|
3
|
-
*
|
|
4
|
-
* runs zero-cache in-process with SINGLE_PROCESS=1 instead of spawning
|
|
5
|
-
* a child process. uses the same TCP proxy approach as startZeroLite()
|
|
6
|
-
* for database connectivity — zero-cache connects to PGlite via the proxy.
|
|
7
|
-
*
|
|
8
|
-
* two modes:
|
|
9
|
-
*
|
|
10
|
-
* 1. **development** (this file): zero-cache uses real postgres package
|
|
11
|
-
* to connect to PGlite via TCP proxy. no bundler aliases needed.
|
|
12
|
-
*
|
|
13
|
-
* 2. **CF Workers** (future): bundler aliases swap postgres/sqlite3 for
|
|
14
|
-
* our shims. no TCP proxy, no port binding, all in-process.
|
|
15
|
-
*
|
|
16
|
-
* env vars:
|
|
17
|
-
* SINGLE_PROCESS=1 — all workers in-process via EventEmitter
|
|
18
|
-
* ZERO_UPSTREAM_DB — postgres connection string (to TCP proxy)
|
|
19
|
-
* ZERO_CVR_DB — postgres connection string (to TCP proxy)
|
|
20
|
-
* ZERO_CHANGE_DB — postgres connection string (to TCP proxy)
|
|
21
|
-
* ZERO_REPLICA_FILE — sqlite replica file path
|
|
22
|
-
* ZERO_PORT — HTTP port for zero-cache dispatcher
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import EventEmitter from 'node:events'
|
|
26
|
-
import { resolve } from 'node:path'
|
|
27
|
-
|
|
28
|
-
import type { PGlite } from '@electric-sql/pglite'
|
|
29
|
-
|
|
30
|
-
export interface ZeroCacheEmbedOptions {
|
|
31
|
-
/** PGlite instance (not used directly — zero-cache connects via TCP proxy) */
|
|
32
|
-
pglite: PGlite
|
|
33
|
-
|
|
34
|
-
/** connection string for the upstream database (postgres://...) */
|
|
35
|
-
upstreamDb: string
|
|
36
|
-
|
|
37
|
-
/** connection string for the CVR database */
|
|
38
|
-
cvrDb: string
|
|
39
|
-
|
|
40
|
-
/** connection string for the change database */
|
|
41
|
-
changeDb: string
|
|
42
|
-
|
|
43
|
-
/** path to the SQLite replica file */
|
|
44
|
-
replicaFile: string
|
|
45
|
-
|
|
46
|
-
/** port for zero-cache HTTP server (0 = random) */
|
|
47
|
-
port?: number
|
|
48
|
-
|
|
49
|
-
/** zero app ID (default: 'zero') */
|
|
50
|
-
appId?: string
|
|
51
|
-
|
|
52
|
-
/** publication names */
|
|
53
|
-
publications?: string[]
|
|
54
|
-
|
|
55
|
-
/** additional env vars passed to zero-cache */
|
|
56
|
-
env?: Record<string, string>
|
|
57
|
-
|
|
58
|
-
/** timeout in ms waiting for zero-cache to be ready (default: 60000) */
|
|
59
|
-
readyTimeout?: number
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface ZeroCacheEmbed {
|
|
63
|
-
/** the port zero-cache is listening on */
|
|
64
|
-
readonly port: number
|
|
65
|
-
|
|
66
|
-
/** whether zero-cache is ready to handle requests */
|
|
67
|
-
readonly ready: boolean
|
|
68
|
-
|
|
69
|
-
/** stop zero-cache and all in-process workers */
|
|
70
|
-
stop(): Promise<void>
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* start zero-cache in embedded (in-process) mode.
|
|
75
|
-
*
|
|
76
|
-
* instead of spawning a child process, imports and runs zero-cache's
|
|
77
|
-
* runWorker() directly with SINGLE_PROCESS=1. all worker coordination
|
|
78
|
-
* happens via EventEmitter IPC channels instead of process.fork().
|
|
79
|
-
*
|
|
80
|
-
* zero-cache still connects to PGlite via the TCP proxy (same as
|
|
81
|
-
* the child process mode), so no bundler aliases are needed.
|
|
82
|
-
*/
|
|
83
|
-
export async function startZeroCacheEmbed(
|
|
84
|
-
opts: ZeroCacheEmbedOptions
|
|
85
|
-
): Promise<ZeroCacheEmbed> {
|
|
86
|
-
const appId = opts.appId || 'zero'
|
|
87
|
-
const publications = opts.publications?.join(',') || `orez_${appId}_public`
|
|
88
|
-
const readyTimeout = opts.readyTimeout ?? 60000
|
|
89
|
-
|
|
90
|
-
// CRITICAL: set SINGLE_PROCESS on process.env BEFORE importing zero-cache.
|
|
91
|
-
// zero-cache's childWorker() and ProcessManager check process.env directly,
|
|
92
|
-
// not the env object passed to runWorker(). without this, zero-cache will
|
|
93
|
-
// fork() child processes instead of using inProcChannel().
|
|
94
|
-
process.env.SINGLE_PROCESS = '1'
|
|
95
|
-
|
|
96
|
-
// also set NODE_ENV on process.env — zero-cache's config normalization
|
|
97
|
-
// reads process.env.NODE_ENV to decide production vs development mode
|
|
98
|
-
const origNodeEnv = process.env.NODE_ENV
|
|
99
|
-
process.env.NODE_ENV = 'development'
|
|
100
|
-
|
|
101
|
-
// build env for zero-cache. these are passed to runWorker() and also
|
|
102
|
-
// propagated to in-process child workers via childWorker().
|
|
103
|
-
const env: Record<string, string> = {
|
|
104
|
-
// inherit process env for NODE_PATH, PATH, etc.
|
|
105
|
-
...(process.env as Record<string, string>),
|
|
106
|
-
// zero-cache config (must come after spread to override)
|
|
107
|
-
SINGLE_PROCESS: '1',
|
|
108
|
-
NODE_ENV: 'development',
|
|
109
|
-
ZERO_UPSTREAM_DB: opts.upstreamDb,
|
|
110
|
-
ZERO_CVR_DB: opts.cvrDb,
|
|
111
|
-
ZERO_CHANGE_DB: opts.changeDb,
|
|
112
|
-
ZERO_REPLICA_FILE: opts.replicaFile,
|
|
113
|
-
ZERO_PORT: String(opts.port ?? 0),
|
|
114
|
-
ZERO_APP_ID: appId,
|
|
115
|
-
ZERO_APP_PUBLICATIONS: publications,
|
|
116
|
-
ZERO_LOG_LEVEL: opts.env?.ZERO_LOG_LEVEL || 'info',
|
|
117
|
-
ZERO_NUM_SYNC_WORKERS: opts.env?.ZERO_NUM_SYNC_WORKERS || '1',
|
|
118
|
-
ZERO_ENABLE_QUERY_PLANNER: 'false',
|
|
119
|
-
...opts.env,
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// create a fake parent that zero-cache's runWorker() can communicate with.
|
|
123
|
-
// in normal mode, this is the child process object. here it's an EventEmitter.
|
|
124
|
-
const parent = new EventEmitter() as EventEmitter & {
|
|
125
|
-
send: (msg: unknown) => boolean
|
|
126
|
-
kill: (signal?: string) => void
|
|
127
|
-
pid: number
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// capture messages from zero-cache
|
|
131
|
-
const parentMessages: unknown[] = []
|
|
132
|
-
const parentEmitter = new EventEmitter()
|
|
133
|
-
|
|
134
|
-
parent.send = (message: unknown) => {
|
|
135
|
-
parentMessages.push(message)
|
|
136
|
-
parentEmitter.emit('message', message)
|
|
137
|
-
return true
|
|
138
|
-
}
|
|
139
|
-
parent.kill = (signal = 'SIGTERM') => {
|
|
140
|
-
parent.emit(signal, signal)
|
|
141
|
-
}
|
|
142
|
-
parent.pid = process.pid
|
|
143
|
-
|
|
144
|
-
// wrap parent with onMessageType/onceMessageType helpers that zero-cache expects
|
|
145
|
-
const wrappedParent = new Proxy(parent, {
|
|
146
|
-
get(target, prop, receiver) {
|
|
147
|
-
if (prop === 'onMessageType') {
|
|
148
|
-
return (type: string, handler: (msg: unknown) => void) => {
|
|
149
|
-
target.on('message', (data: unknown) => {
|
|
150
|
-
if (Array.isArray(data) && data.length === 2 && data[0] === type) {
|
|
151
|
-
handler(data[1])
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
return receiver
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (prop === 'onceMessageType') {
|
|
158
|
-
return (type: string, handler: (msg: unknown) => void) => {
|
|
159
|
-
const listener = (data: unknown) => {
|
|
160
|
-
if (Array.isArray(data) && data.length === 2 && data[0] === type) {
|
|
161
|
-
target.off('message', listener)
|
|
162
|
-
handler(data[1])
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
target.on('message', listener)
|
|
166
|
-
return receiver
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return Reflect.get(target, prop, receiver)
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
// import and start zero-cache's runner
|
|
174
|
-
let runWorkerFn: (parent: unknown, env: Record<string, string>) => Promise<void>
|
|
175
|
-
try {
|
|
176
|
-
// @rocicorp/zero's package.json exports don't expose internal modules,
|
|
177
|
-
// so we resolve the full filesystem path and import directly.
|
|
178
|
-
const { createRequire } = await import('node:module')
|
|
179
|
-
const require = createRequire(import.meta.url)
|
|
180
|
-
const zeroEntry = require.resolve('@rocicorp/zero')
|
|
181
|
-
const runWorkerPath = zeroEntry.replace(
|
|
182
|
-
/\/out\/.*$/,
|
|
183
|
-
'/out/zero-cache/src/server/runner/run-worker.js'
|
|
184
|
-
)
|
|
185
|
-
const mod = await (import(runWorkerPath) as Promise<{
|
|
186
|
-
runWorker: typeof runWorkerFn
|
|
187
|
-
}>)
|
|
188
|
-
runWorkerFn = mod.runWorker
|
|
189
|
-
} catch (err) {
|
|
190
|
-
throw new Error(
|
|
191
|
-
`failed to import zero-cache runWorker: ${err}. ` +
|
|
192
|
-
'ensure @rocicorp/zero is installed.'
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// track state
|
|
197
|
-
let isReady = false
|
|
198
|
-
let resolvedPort = opts.port ?? 0
|
|
199
|
-
let runWorkerPromise: Promise<void> | null = null
|
|
200
|
-
|
|
201
|
-
// wait for "ready" message from zero-cache
|
|
202
|
-
const readyPromise = new Promise<void>((resolve, reject) => {
|
|
203
|
-
const timeout = setTimeout(() => {
|
|
204
|
-
reject(
|
|
205
|
-
new Error(`zero-cache embed: timed out waiting for ready after ${readyTimeout}ms`)
|
|
206
|
-
)
|
|
207
|
-
}, readyTimeout)
|
|
208
|
-
|
|
209
|
-
parentEmitter.on('message', (msg: unknown) => {
|
|
210
|
-
if (Array.isArray(msg) && msg[0] === 'ready') {
|
|
211
|
-
clearTimeout(timeout)
|
|
212
|
-
isReady = true
|
|
213
|
-
resolve()
|
|
214
|
-
}
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
// intercept process.exit() — zero-cache's ProcessManager may call it
|
|
219
|
-
// during shutdown even in single-process mode (nested ProcessManagers).
|
|
220
|
-
// we convert it to a no-op and handle cleanup ourselves.
|
|
221
|
-
const origExit = process.exit
|
|
222
|
-
process.exit = ((code?: number) => {
|
|
223
|
-
// don't actually exit — just emit on parent to trigger cleanup
|
|
224
|
-
parent.emit('exit', code ?? 0)
|
|
225
|
-
}) as never
|
|
226
|
-
|
|
227
|
-
// start runWorker (runs until killed)
|
|
228
|
-
runWorkerPromise = runWorkerFn(wrappedParent, env).catch((err) => {
|
|
229
|
-
if (!isReady) {
|
|
230
|
-
throw err
|
|
231
|
-
}
|
|
232
|
-
// after ready, errors during shutdown are expected
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
// wait for zero-cache to be ready
|
|
236
|
-
await readyPromise
|
|
237
|
-
|
|
238
|
-
// if port was 0, we need to discover the actual port.
|
|
239
|
-
// zero-cache logs the address but doesn't expose it programmatically.
|
|
240
|
-
// for now, if port=0, the caller needs to discover it themselves.
|
|
241
|
-
if (opts.port && opts.port > 0) {
|
|
242
|
-
resolvedPort = opts.port
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
get port() {
|
|
247
|
-
return resolvedPort
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
get ready() {
|
|
251
|
-
return isReady
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
async stop() {
|
|
255
|
-
isReady = false
|
|
256
|
-
// send SIGTERM to trigger graceful shutdown
|
|
257
|
-
wrappedParent.kill('SIGTERM')
|
|
258
|
-
// wait for runWorker to finish (with timeout).
|
|
259
|
-
// IMPORTANT: do NOT clean up process.env.SINGLE_PROCESS until after
|
|
260
|
-
// runWorker completes — the ProcessManager's async exit handler
|
|
261
|
-
// checks singleProcessMode() and must find it still set.
|
|
262
|
-
if (runWorkerPromise) {
|
|
263
|
-
await Promise.race([runWorkerPromise, new Promise((r) => setTimeout(r, 5000))])
|
|
264
|
-
}
|
|
265
|
-
// give async exit handlers time to complete
|
|
266
|
-
await new Promise((r) => setTimeout(r, 200))
|
|
267
|
-
// now safe to restore process.exit and process.env
|
|
268
|
-
process.exit = origExit
|
|
269
|
-
delete process.env.SINGLE_PROCESS
|
|
270
|
-
if (origNodeEnv !== undefined) {
|
|
271
|
-
process.env.NODE_ENV = origNodeEnv
|
|
272
|
-
} else {
|
|
273
|
-
delete process.env.NODE_ENV
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
}
|
|
277
|
-
}
|