@livestore/utils-dev 0.4.0-dev.7 → 0.4.0-dev.8
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/.tsbuildinfo.json +1 -1
- package/dist/node/DockerComposeService/DockerComposeService.d.ts +14 -4
- package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -1
- package/dist/node/DockerComposeService/DockerComposeService.js +27 -10
- package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -1
- package/dist/node/mod.d.ts +0 -2
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +0 -2
- package/dist/node/mod.js.map +1 -1
- package/dist/node-vitest/Vitest.d.ts +6 -6
- package/dist/node-vitest/Vitest.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.js +2 -2
- package/dist/node-vitest/Vitest.js.map +1 -1
- package/dist/node-vitest/Vitest.test.js +12 -1
- package/dist/node-vitest/Vitest.test.js.map +1 -1
- package/dist/{node/WranglerDevServer → wrangler}/WranglerDevServer.d.ts +6 -6
- package/dist/wrangler/WranglerDevServer.d.ts.map +1 -0
- package/dist/wrangler/WranglerDevServer.js +90 -0
- package/dist/wrangler/WranglerDevServer.js.map +1 -0
- package/dist/wrangler/WranglerDevServer.test.d.ts.map +1 -0
- package/dist/wrangler/WranglerDevServer.test.js +77 -0
- package/dist/wrangler/WranglerDevServer.test.js.map +1 -0
- package/dist/wrangler/fixtures/cf-worker.d.ts.map +1 -0
- package/dist/wrangler/fixtures/cf-worker.js.map +1 -0
- package/dist/wrangler/mod.d.ts +2 -0
- package/dist/wrangler/mod.d.ts.map +1 -0
- package/dist/wrangler/mod.js +2 -0
- package/dist/wrangler/mod.js.map +1 -0
- package/package.json +7 -4
- package/src/node/DockerComposeService/DockerComposeService.ts +50 -10
- package/src/node/mod.ts +0 -7
- package/src/node-vitest/Vitest.test.ts +12 -1
- package/src/node-vitest/Vitest.ts +31 -19
- package/src/wrangler/WranglerDevServer.test.ts +133 -0
- package/src/wrangler/WranglerDevServer.ts +180 -0
- package/src/wrangler/mod.ts +6 -0
- package/dist/node/WranglerDevServer/WranglerDevServer.d.ts.map +0 -1
- package/dist/node/WranglerDevServer/WranglerDevServer.js +0 -122
- package/dist/node/WranglerDevServer/WranglerDevServer.js.map +0 -1
- package/dist/node/WranglerDevServer/WranglerDevServer.test.d.ts.map +0 -1
- package/dist/node/WranglerDevServer/WranglerDevServer.test.js +0 -179
- package/dist/node/WranglerDevServer/WranglerDevServer.test.js.map +0 -1
- package/dist/node/WranglerDevServer/fixtures/cf-worker.d.ts.map +0 -1
- package/dist/node/WranglerDevServer/fixtures/cf-worker.js.map +0 -1
- package/dist/node/WranglerDevServer/process-tree-manager.d.ts +0 -55
- package/dist/node/WranglerDevServer/process-tree-manager.d.ts.map +0 -1
- package/dist/node/WranglerDevServer/process-tree-manager.js +0 -178
- package/dist/node/WranglerDevServer/process-tree-manager.js.map +0 -1
- package/dist/node/vitest-docker-compose-setup.d.ts +0 -32
- package/dist/node/vitest-docker-compose-setup.d.ts.map +0 -1
- package/dist/node/vitest-docker-compose-setup.js +0 -131
- package/dist/node/vitest-docker-compose-setup.js.map +0 -1
- package/dist/node/vitest-wrangler-setup.d.ts +0 -27
- package/dist/node/vitest-wrangler-setup.d.ts.map +0 -1
- package/dist/node/vitest-wrangler-setup.js +0 -96
- package/dist/node/vitest-wrangler-setup.js.map +0 -1
- package/dist/node-vitest/polyfill.d.ts +0 -2
- package/dist/node-vitest/polyfill.d.ts.map +0 -1
- package/dist/node-vitest/polyfill.js +0 -3
- package/dist/node-vitest/polyfill.js.map +0 -1
- package/src/node/WranglerDevServer/WranglerDevServer.test.ts +0 -266
- package/src/node/WranglerDevServer/WranglerDevServer.ts +0 -266
- package/src/node/WranglerDevServer/process-tree-manager.ts +0 -263
- /package/dist/{node/WranglerDevServer → wrangler}/WranglerDevServer.test.d.ts +0 -0
- /package/dist/{node/WranglerDevServer → wrangler}/fixtures/cf-worker.d.ts +0 -0
- /package/dist/{node/WranglerDevServer → wrangler}/fixtures/cf-worker.js +0 -0
- /package/src/{node/WranglerDevServer → wrangler}/fixtures/cf-worker.ts +0 -0
- /package/src/{node/WranglerDevServer → wrangler}/fixtures/wrangler.toml +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { IS_CI } from '@livestore/utils';
|
|
3
|
-
import { Command, Duration, Effect, Exit, HttpClient, Schedule, Schema, Stream, } from '@livestore/utils/effect';
|
|
4
|
-
import { getFreePort } from '@livestore/utils/node';
|
|
5
|
-
import { cleanupOrphanedProcesses, killProcessTree } from "./process-tree-manager.js";
|
|
6
|
-
/**
|
|
7
|
-
* Error type for WranglerDevServer operations
|
|
8
|
-
*/
|
|
9
|
-
export class WranglerDevServerError extends Schema.TaggedError()('WranglerDevServerError', {
|
|
10
|
-
cause: Schema.Unknown,
|
|
11
|
-
message: Schema.String,
|
|
12
|
-
port: Schema.Number,
|
|
13
|
-
}) {
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* WranglerDevServer as an Effect.Service.
|
|
17
|
-
*
|
|
18
|
-
* This service provides the WranglerDevServer properties and can be accessed
|
|
19
|
-
* directly to get port, url, and processId.
|
|
20
|
-
*
|
|
21
|
-
* TODO: Allow for config to be passed in via code instead of `wrangler.toml` file
|
|
22
|
-
* (would need to be placed in temporary file as wrangler only accepts files as config)
|
|
23
|
-
*/
|
|
24
|
-
export class WranglerDevServerService extends Effect.Service()('WranglerDevServerService', {
|
|
25
|
-
scoped: (args) => Effect.gen(function* () {
|
|
26
|
-
const showLogs = args.showLogs ?? false;
|
|
27
|
-
// Clean up any orphaned processes before starting (defensive cleanup)
|
|
28
|
-
yield* cleanupOrphanedProcesses(['wrangler', 'workerd']).pipe(Effect.tap((result) => showLogs && (result.cleaned.length > 0 || result.failed.length > 0)
|
|
29
|
-
? Effect.logInfo(`Cleanup result: ${result.cleaned.length} cleaned, ${result.failed.length} failed`)
|
|
30
|
-
: Effect.void), Effect.ignore);
|
|
31
|
-
// Allocate port
|
|
32
|
-
const port = args.port ??
|
|
33
|
-
(yield* getFreePort.pipe(Effect.mapError((cause) => new WranglerDevServerError({ cause, message: 'Failed to get free port', port: -1 }))));
|
|
34
|
-
yield* Effect.annotateCurrentSpan({ port });
|
|
35
|
-
// Resolve config path
|
|
36
|
-
const configPath = path.resolve(args.wranglerConfigPath ?? path.join(args.cwd, 'wrangler.toml'));
|
|
37
|
-
// Start wrangler process using Effect Command
|
|
38
|
-
const process = yield* Command.make('bunx', 'wrangler', 'dev', '--port', port.toString(), '--config', configPath).pipe(Command.workingDirectory(args.cwd), Command.stdout('pipe'), Command.stderr('pipe'), Command.start, Effect.catchAllCause((error) => new WranglerDevServerError({
|
|
39
|
-
cause: error,
|
|
40
|
-
message: `Failed to start wrangler process in directory: ${args.cwd}`,
|
|
41
|
-
port,
|
|
42
|
-
})), Effect.withSpan('WranglerDevServerService:startProcess'));
|
|
43
|
-
if (showLogs) {
|
|
44
|
-
yield* process.stderr.pipe(Stream.decodeText('utf8'), Stream.tapLogWithLabel('wrangler:stderr'), Stream.runDrain, Effect.forkScoped);
|
|
45
|
-
}
|
|
46
|
-
const processId = process.pid;
|
|
47
|
-
// We need to keep the `stdout` stream open, as we drain it in the waitForReady function
|
|
48
|
-
// Otherwise we'll get a EPIPE error
|
|
49
|
-
const stdout = yield* Stream.broadcastDynamic(process.stdout, 100);
|
|
50
|
-
// Register cleanup finalizer with intelligent timeout handling
|
|
51
|
-
yield* Effect.addFinalizer((exit) => Effect.gen(function* () {
|
|
52
|
-
const isInterrupted = Exit.isInterrupted(exit);
|
|
53
|
-
if (showLogs) {
|
|
54
|
-
yield* Effect.logDebug(`Cleaning up wrangler process ${processId}, interrupted: ${isInterrupted}`);
|
|
55
|
-
}
|
|
56
|
-
// yield* Effect.logDebug(`Cleaning up wrangler process ${processId}, interrupted: ${isInterrupted}`)
|
|
57
|
-
// Check if process is still running
|
|
58
|
-
const isRunning = yield* process.isRunning;
|
|
59
|
-
if (isRunning) {
|
|
60
|
-
// Use our enhanced process tree cleanup
|
|
61
|
-
yield* killProcessTree(processId, {
|
|
62
|
-
timeout: isInterrupted ? 500 : 3000, // Fast cleanup on interruption
|
|
63
|
-
signals: ['SIGTERM', 'SIGKILL'],
|
|
64
|
-
includeRoot: true,
|
|
65
|
-
}).pipe(Effect.tap((result) => showLogs
|
|
66
|
-
? Effect.logDebug(`Cleaned up ${result.killedPids.length} processes, ${result.failedPids.length} failed`)
|
|
67
|
-
: Effect.void), Effect.mapError((error) => new WranglerDevServerError({
|
|
68
|
-
cause: error,
|
|
69
|
-
message: `Failed to kill process tree for PID ${processId}`,
|
|
70
|
-
port: 0,
|
|
71
|
-
})), Effect.ignore);
|
|
72
|
-
// Also kill the command process handle
|
|
73
|
-
yield* process.kill();
|
|
74
|
-
}
|
|
75
|
-
else if (showLogs) {
|
|
76
|
-
yield* Effect.logDebug(`Process ${processId} already terminated`);
|
|
77
|
-
}
|
|
78
|
-
}).pipe(Effect.withSpan('WranglerDevServerService:cleanupProcess'), Effect.timeout('5 seconds'), // Don't let cleanup hang forever
|
|
79
|
-
Effect.ignoreLogged));
|
|
80
|
-
// Wait for server to be ready
|
|
81
|
-
yield* waitForReady({ stdout, showLogs });
|
|
82
|
-
const url = `http://localhost:${port}`;
|
|
83
|
-
// Use longer timeout in CI environments to account for slower startup times
|
|
84
|
-
const defaultTimeout = Duration.seconds(IS_CI ? 15 : 5);
|
|
85
|
-
yield* verifyHttpConnectivity({ url, showLogs, connectTimeout: args.connectTimeout ?? defaultTimeout });
|
|
86
|
-
if (showLogs) {
|
|
87
|
-
yield* Effect.logDebug(`Wrangler dev server ready and accepting connections on port ${port}`);
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
port,
|
|
91
|
-
url,
|
|
92
|
-
processId,
|
|
93
|
-
};
|
|
94
|
-
}).pipe(Effect.withSpan('WranglerDevServerService', {
|
|
95
|
-
attributes: { port: args.port ?? 'auto', cwd: args.cwd },
|
|
96
|
-
})),
|
|
97
|
-
}) {
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Waits for Wrangler server to be ready by monitoring stdout for "Ready on" message
|
|
101
|
-
*/
|
|
102
|
-
const waitForReady = ({ stdout, showLogs, }) => stdout.pipe(Stream.decodeText('utf8'), Stream.splitLines, Stream.tap((line) => (showLogs ? Effect.logDebug(`[wrangler] ${line}`) : Effect.void)), Stream.takeUntil((line) => line.includes('Ready on')), Stream.runDrain, Effect.timeout('30 seconds'), Effect.mapError((error) => new WranglerDevServerError({
|
|
103
|
-
cause: error,
|
|
104
|
-
message: 'Wrangler server failed to start within timeout',
|
|
105
|
-
port: 0,
|
|
106
|
-
})));
|
|
107
|
-
/**
|
|
108
|
-
* Verifies the server is actually accepting HTTP connections by making a test request
|
|
109
|
-
*/
|
|
110
|
-
const verifyHttpConnectivity = ({ url, showLogs, connectTimeout, }) => Effect.gen(function* () {
|
|
111
|
-
const client = yield* HttpClient.HttpClient;
|
|
112
|
-
if (showLogs) {
|
|
113
|
-
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`);
|
|
114
|
-
}
|
|
115
|
-
// Try to connect with retries using exponential backoff
|
|
116
|
-
yield* client.get(url).pipe(Effect.retryOrElse(Schedule.exponential('50 millis', 2).pipe(Schedule.jittered, Schedule.intersect(Schedule.elapsed.pipe(Schedule.whileOutput(Duration.lessThanOrEqualTo(connectTimeout)))), Schedule.compose(Schedule.count)), (error, attemptCount) => Effect.fail(new WranglerDevServerError({
|
|
117
|
-
cause: error,
|
|
118
|
-
message: `Failed to establish HTTP connection to Wrangler server at ${url} after ${attemptCount} attempts (timeout: ${Duration.toMillis(connectTimeout)}ms)`,
|
|
119
|
-
port: 0,
|
|
120
|
-
}))), Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)), Effect.asVoid, Effect.withSpan('verifyHttpConnectivity'));
|
|
121
|
-
});
|
|
122
|
-
//# sourceMappingURL=WranglerDevServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../../src/node/WranglerDevServer/WranglerDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,UAAU,EAEV,QAAQ,EACR,MAAM,EACN,MAAM,GACP,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAErF;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CAAC,wBAAwB,EAAE;IACjH,KAAK,EAAE,MAAM,CAAC,OAAO;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;CAAG;AAuBL;;;;;;;;GAQG;AACH,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,OAAO,EAA4B,CAAC,0BAA0B,EAAE;IACnH,MAAM,EAAE,CAAC,IAAgC,EAAE,EAAE,CAC3C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAA;QAEvC,sEAAsE;QACtE,KAAK,CAAC,CAAC,wBAAwB,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAC3D,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACpB,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YACjE,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-
{"version":3,"file":"WranglerDevServer.test.d.ts","sourceRoot":"","sources":["../../../src/node/WranglerDevServer/WranglerDevServer.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Effect, Exit, FetchHttpClient, Fiber, Layer, Scope } from '@livestore/utils/effect';
|
|
2
|
-
import { PlatformNode } from '@livestore/utils/node';
|
|
3
|
-
import { Vitest } from '@livestore/utils-dev/node-vitest';
|
|
4
|
-
import { expect } from 'vitest';
|
|
5
|
-
import { WranglerDevServerError, WranglerDevServerService, } from "./WranglerDevServer.js";
|
|
6
|
-
const testTimeout = 60_000;
|
|
7
|
-
const withTestCtx = Vitest.makeWithTestCtx({
|
|
8
|
-
timeout: testTimeout,
|
|
9
|
-
makeLayer: () => PlatformNode.NodeContext.layer,
|
|
10
|
-
});
|
|
11
|
-
const WranglerDevServerTest = (args = {}) => WranglerDevServerService.Default({
|
|
12
|
-
cwd: `${import.meta.dirname}/fixtures`,
|
|
13
|
-
...args,
|
|
14
|
-
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
15
|
-
Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
|
|
16
|
-
Vitest.describe('Basic Operations', () => {
|
|
17
|
-
const withBasicTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
18
|
-
timeout: testTimeout,
|
|
19
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
|
|
20
|
-
});
|
|
21
|
-
Vitest.scopedLive('should start wrangler dev server and return port', (test) => Effect.gen(function* () {
|
|
22
|
-
const server = yield* WranglerDevServerService;
|
|
23
|
-
expect(server.port).toBeGreaterThan(0);
|
|
24
|
-
expect(server.url).toMatch(/http:\/\/localhost:\d+/);
|
|
25
|
-
expect(typeof server.processId).toBe('number');
|
|
26
|
-
expect(server.processId).toBeGreaterThan(0);
|
|
27
|
-
}).pipe(withBasicTest()(test)));
|
|
28
|
-
Vitest.scopedLive('should use specified port when provided', (test) => Effect.gen(function* () {
|
|
29
|
-
const server = yield* WranglerDevServerService;
|
|
30
|
-
expect(server.port).toBe(54443);
|
|
31
|
-
expect(server.url).toBe(`http://localhost:54443`);
|
|
32
|
-
}).pipe(withBasicTest({ port: 54443 })(test)));
|
|
33
|
-
});
|
|
34
|
-
Vitest.describe('Resource Management', () => {
|
|
35
|
-
Vitest.scopedLive('should cleanup processes on scope close', (test) => Effect.gen(function* () {
|
|
36
|
-
let processId;
|
|
37
|
-
// Create a separate scope for the server
|
|
38
|
-
const serverScope = yield* Scope.make();
|
|
39
|
-
const server = yield* Effect.provide(WranglerDevServerService, WranglerDevServerTest().pipe(Layer.provide(PlatformNode.NodeContext.layer))).pipe(Scope.extend(serverScope));
|
|
40
|
-
processId = server.processId;
|
|
41
|
-
expect(processId).toBeGreaterThan(0);
|
|
42
|
-
expect(server.port).toBeGreaterThan(0);
|
|
43
|
-
expect(server.url).toMatch(/http:\/\/localhost:\d+/);
|
|
44
|
-
// Close scope to trigger cleanup
|
|
45
|
-
yield* Scope.close(serverScope, Exit.succeed(void 0));
|
|
46
|
-
// Wait for cleanup to complete
|
|
47
|
-
yield* Effect.sleep('2 seconds');
|
|
48
|
-
// Verify process is terminated
|
|
49
|
-
const isRunning2 = yield* Effect.promise(() => {
|
|
50
|
-
try {
|
|
51
|
-
process.kill(processId, 0);
|
|
52
|
-
return Promise.resolve(true);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return Promise.resolve(false);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
expect(isRunning2).toBe(false);
|
|
59
|
-
}).pipe(withTestCtx(test)));
|
|
60
|
-
Vitest.scopedLive('should handle interruption with fast cleanup', (test) => Effect.gen(function* () {
|
|
61
|
-
let processId;
|
|
62
|
-
const fiber = yield* Effect.fork(Effect.provide(Effect.gen(function* () {
|
|
63
|
-
const server = yield* WranglerDevServerService;
|
|
64
|
-
processId = server.processId;
|
|
65
|
-
yield* Effect.sleep('30 seconds'); // Keep running
|
|
66
|
-
return server;
|
|
67
|
-
}), WranglerDevServerTest().pipe(Layer.provide(PlatformNode.NodeContext.layer))));
|
|
68
|
-
// Wait for server to start
|
|
69
|
-
yield* Effect.sleep('3 seconds');
|
|
70
|
-
expect(processId).toBeGreaterThan(0);
|
|
71
|
-
// Interrupt and measure cleanup time
|
|
72
|
-
const start = Date.now();
|
|
73
|
-
yield* Fiber.interrupt(fiber);
|
|
74
|
-
const elapsed = Date.now() - start;
|
|
75
|
-
// Should use fast cleanup (500ms timeout) + some overhead
|
|
76
|
-
expect(elapsed).toBeLessThan(1500); // Allow some overhead
|
|
77
|
-
// Wait for cleanup to complete
|
|
78
|
-
yield* Effect.sleep('1 second');
|
|
79
|
-
// Verify process is terminated
|
|
80
|
-
const isRunningAfter = yield* Effect.promise(() => {
|
|
81
|
-
try {
|
|
82
|
-
process.kill(processId, 0);
|
|
83
|
-
return Promise.resolve(true);
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return Promise.resolve(false);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
expect(isRunningAfter).toBe(false);
|
|
90
|
-
}).pipe(withTestCtx(test)));
|
|
91
|
-
});
|
|
92
|
-
Vitest.describe('Error Handling', () => {
|
|
93
|
-
const withErrorTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
94
|
-
timeout: testTimeout,
|
|
95
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
|
|
96
|
-
});
|
|
97
|
-
Vitest.scopedLive('should handle missing wrangler.toml but should timeout', (test) => Effect.gen(function* () {
|
|
98
|
-
const error = yield* WranglerDevServerService.pipe(Effect.provide(WranglerDevServerTest({
|
|
99
|
-
cwd: '/tmp',
|
|
100
|
-
wranglerConfigPath: '/dev/null',
|
|
101
|
-
connectTimeout: '500 millis',
|
|
102
|
-
}).pipe(Layer.provide(PlatformNode.NodeContext.layer))), Effect.flip);
|
|
103
|
-
expect(error).toBeInstanceOf(WranglerDevServerError);
|
|
104
|
-
}).pipe(Vitest.withTestCtx(test)));
|
|
105
|
-
Vitest.scopedLive('should handle invalid working directory', (test) => Effect.gen(function* () {
|
|
106
|
-
const result = yield* WranglerDevServerService.pipe(Effect.provide(WranglerDevServerTest({
|
|
107
|
-
cwd: '/completely/nonexistent/directory',
|
|
108
|
-
}).pipe(Layer.provide(PlatformNode.NodeContext.layer))), Effect.either);
|
|
109
|
-
expect(result._tag).toBe('Left');
|
|
110
|
-
if (result._tag === 'Left') {
|
|
111
|
-
expect(result.left).toBeInstanceOf(WranglerDevServerError);
|
|
112
|
-
}
|
|
113
|
-
}).pipe(Vitest.withTestCtx(test)));
|
|
114
|
-
Vitest.scopedLive('should timeout if server fails to start', (test) => Effect.gen(function* () {
|
|
115
|
-
// Create a command that will never output "Ready on"
|
|
116
|
-
const result = yield* WranglerDevServerService.pipe(
|
|
117
|
-
// Override the timeout for this test to be shorter
|
|
118
|
-
Effect.timeout('5 seconds'), Effect.either);
|
|
119
|
-
// This might succeed or fail depending on actual wrangler behavior
|
|
120
|
-
// The main point is testing timeout functionality
|
|
121
|
-
expect(['Left', 'Right']).toContain(result._tag);
|
|
122
|
-
}).pipe(withErrorTest()(test)));
|
|
123
|
-
});
|
|
124
|
-
Vitest.describe('Process Tree Cleanup', () => {
|
|
125
|
-
const withCleanupTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
126
|
-
timeout: testTimeout,
|
|
127
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
|
|
128
|
-
});
|
|
129
|
-
Vitest.scopedLive('should clean up child workerd processes', (test) => Effect.gen(function* () {
|
|
130
|
-
let processId;
|
|
131
|
-
const server = yield* WranglerDevServerService;
|
|
132
|
-
processId = server.processId;
|
|
133
|
-
// Wait for wrangler to spawn workerd children
|
|
134
|
-
yield* Effect.sleep('3 seconds');
|
|
135
|
-
// Find any child processes (workerd)
|
|
136
|
-
const children = yield* Effect.promise(async () => {
|
|
137
|
-
const { exec } = require('node:child_process');
|
|
138
|
-
const { promisify } = require('node:util');
|
|
139
|
-
const execAsync = promisify(exec);
|
|
140
|
-
try {
|
|
141
|
-
if (!processId)
|
|
142
|
-
throw new Error('processId is undefined');
|
|
143
|
-
const { stdout } = await execAsync(`ps -o pid,ppid -ax | grep -E "^\\s*[0-9]+\\s+${processId}\\s*$"`);
|
|
144
|
-
return stdout
|
|
145
|
-
.trim()
|
|
146
|
-
.split('\n')
|
|
147
|
-
.map((line) => {
|
|
148
|
-
const match = line.trim().match(/^\s*(\d+)\s+\d+\s*$/);
|
|
149
|
-
return match?.[1] ? Number.parseInt(match[1], 10) : null;
|
|
150
|
-
})
|
|
151
|
-
.filter((pid) => pid !== null);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
console.log(`Found ${children.length} child processes:`, children);
|
|
158
|
-
// The scope will close here and should clean up all processes
|
|
159
|
-
}).pipe(withCleanupTest()(test)));
|
|
160
|
-
});
|
|
161
|
-
Vitest.describe('Service Pattern', () => {
|
|
162
|
-
const withServiceTest = (args = {}) => Vitest.makeWithTestCtx({
|
|
163
|
-
timeout: testTimeout,
|
|
164
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
|
|
165
|
-
});
|
|
166
|
-
Vitest.scopedLive('should work with service pattern', (test) => Effect.gen(function* () {
|
|
167
|
-
const server = yield* WranglerDevServerService;
|
|
168
|
-
expect(server.port).toBeGreaterThan(0);
|
|
169
|
-
expect(server.url).toMatch(/http:\/\/localhost:\d+/);
|
|
170
|
-
expect(server.processId).toBeGreaterThan(0);
|
|
171
|
-
}).pipe(withServiceTest()(test)));
|
|
172
|
-
Vitest.scopedLive('should work with custom port via service', (test) => Effect.gen(function* () {
|
|
173
|
-
const server = yield* WranglerDevServerService;
|
|
174
|
-
expect(server.port).toBe(54444);
|
|
175
|
-
expect(server.url).toBe('http://localhost:54444');
|
|
176
|
-
}).pipe(withServiceTest({ port: 54444 })(test)));
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
//# sourceMappingURL=WranglerDevServer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.test.js","sourceRoot":"","sources":["../../../src/node/WranglerDevServer/WranglerDevServer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAEL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,GAAG,MAAM,CAAA;AAE1B,MAAM,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC;IACzC,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK;CAChD,CAAC,CAAA;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAA4C,EAAE,EAAE,EAAE,CAC/E,wBAAwB,CAAC,OAAO,CAAC;IAC/B,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW;IACtC,GAAG,IAAI;CACR,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AAE/C,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE;IAClE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACvC,MAAM,aAAa,GAAG,CAAC,O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 -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cf-worker.d.ts","sourceRoot":"","sources":["../../../../src/node/WranglerDevServer/fixtures/cf-worker.ts"],"names":[],"mappings":";oBACwB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADnD,wBAIC;AAED,qBAAa,MAAM;IACX,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cf-worker.js","sourceRoot":"","sources":["../../../../src/node/WranglerDevServer/fixtures/cf-worker.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,KAAK,CAAC,KAAK,CAAC,QAAiB;QAC3B,OAAO,IAAI,QAAQ,CAAC,6CAA6C,CAAC,CAAA;IACpE,CAAC;CACF,CAAA;AAED,MAAM,OAAO,MAAM;IACjB,KAAK,CAAC,KAAK,CAAC,QAAiB;QAC3B,OAAO,IAAI,QAAQ,CAAC,iCAAiC,CAAC,CAAA;IACxD,CAAC;CACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type CommandExecutor, Effect, Schema, type Scope } from '@livestore/utils/effect';
|
|
2
|
-
declare const ProcessTreeError_base: Schema.TaggedErrorClass<ProcessTreeError, "ProcessTreeError", {
|
|
3
|
-
readonly _tag: Schema.tag<"ProcessTreeError">;
|
|
4
|
-
} & {
|
|
5
|
-
cause: typeof Schema.Unknown;
|
|
6
|
-
message: typeof Schema.String;
|
|
7
|
-
pid: typeof Schema.Number;
|
|
8
|
-
}>;
|
|
9
|
-
export declare class ProcessTreeError extends ProcessTreeError_base {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Finds all child processes of a given parent PID
|
|
13
|
-
*/
|
|
14
|
-
export declare const findChildProcesses: (parentPid: number) => Effect.Effect<number[], never, CommandExecutor.CommandExecutor | Scope.Scope>;
|
|
15
|
-
/**
|
|
16
|
-
* Recursively finds all descendants of a process
|
|
17
|
-
*/
|
|
18
|
-
export declare const findProcessTree: (rootPid: number) => Effect.Effect<number[], never, CommandExecutor.CommandExecutor | Scope.Scope>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if a process is running
|
|
21
|
-
*/
|
|
22
|
-
export declare const isProcessRunning: (pid: number) => Effect.Effect<boolean, never, never>;
|
|
23
|
-
/**
|
|
24
|
-
* Kills a process tree with escalating signals
|
|
25
|
-
*/
|
|
26
|
-
export declare const killProcessTree: (rootPid: number, options?: {
|
|
27
|
-
timeout?: number;
|
|
28
|
-
signals?: NodeJS.Signals[];
|
|
29
|
-
includeRoot?: boolean;
|
|
30
|
-
}) => Effect.Effect<{
|
|
31
|
-
killedPids: number[];
|
|
32
|
-
failedPids: number[];
|
|
33
|
-
}, never, CommandExecutor.CommandExecutor | Scope.Scope>;
|
|
34
|
-
/**
|
|
35
|
-
* Finds orphaned processes by name pattern
|
|
36
|
-
*/
|
|
37
|
-
export declare const findOrphanedProcesses: (namePattern: string) => Effect.Effect<number[], never, CommandExecutor.CommandExecutor | Scope.Scope>;
|
|
38
|
-
/**
|
|
39
|
-
* Defensive cleanup for orphaned processes matching given patterns.
|
|
40
|
-
*
|
|
41
|
-
* This function provides fallback cleanup for edge cases where normal process
|
|
42
|
-
* termination mechanisms fail (e.g., hard crashes, SIGKILL before cleanup runs,
|
|
43
|
-
* or limitations in synchronous exit handlers). While proper process tree cleanup
|
|
44
|
-
* should prevent orphans in most cases, this serves as a safety net for scenarios
|
|
45
|
-
* where child processes become orphaned despite cleanup efforts.
|
|
46
|
-
*
|
|
47
|
-
* @param processPatterns - Array of process name patterns to search for (e.g., ['wrangler', 'workerd'])
|
|
48
|
-
* @returns Object with arrays of successfully cleaned and failed PIDs
|
|
49
|
-
*/
|
|
50
|
-
export declare const cleanupOrphanedProcesses: (processPatterns: string[]) => Effect.Effect<{
|
|
51
|
-
cleaned: number[];
|
|
52
|
-
failed: number[];
|
|
53
|
-
}, never, CommandExecutor.CommandExecutor | Scope.Scope>;
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=process-tree-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-tree-manager.d.ts","sourceRoot":"","sources":["../../../src/node/WranglerDevServer/process-tree-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAU,MAAM,yBAAyB,CAAA;;;;;;;;AAE3G,qBAAa,gBAAiB,SAAQ,qBAIpC;CAAG;AAEL;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CA2B3E,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CAkB3E,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAQ9E,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,UAAS;IACP,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAA;CACjB,KACL,MAAM,CAAC,MAAM,CACd;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,EAC9C,KAAK,EACL,eAAe,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CAsE3C,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,MAAM,KAClB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,eAAe,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CA8B3E,CAAA;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,iBAAiB,MAAM,EAAE,KACxB,MAAM,CAAC,MAAM,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,KAAK,EAAE,eAAe,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CA8C1G,CAAA"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Command, Effect, Schema, Stream } from '@livestore/utils/effect';
|
|
2
|
-
export class ProcessTreeError extends Schema.TaggedError()('ProcessTreeError', {
|
|
3
|
-
cause: Schema.Unknown,
|
|
4
|
-
message: Schema.String,
|
|
5
|
-
pid: Schema.Number,
|
|
6
|
-
}) {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Finds all child processes of a given parent PID
|
|
10
|
-
*/
|
|
11
|
-
export const findChildProcesses = (parentPid) => Effect.gen(function* () {
|
|
12
|
-
const result = yield* Command.make('ps', '-o', 'pid,ppid', '-ax').pipe(Command.start, Effect.flatMap((command) => command.stdout.pipe(Stream.decodeText('utf8'), Stream.runCollect, Effect.map((chunks) => Array.from(chunks).join('')))), Effect.catchAll(() => Effect.succeed('')));
|
|
13
|
-
if (!result)
|
|
14
|
-
return [];
|
|
15
|
-
const lines = result.split('\n');
|
|
16
|
-
const pattern = new RegExp(`^\\s*([0-9]+)\\s+${parentPid}\\s*$`);
|
|
17
|
-
const childPids = lines
|
|
18
|
-
.map((line) => {
|
|
19
|
-
const match = line.trim().match(pattern);
|
|
20
|
-
return match ? Number.parseInt(match[1], 10) : null;
|
|
21
|
-
})
|
|
22
|
-
.filter((pid) => pid !== null);
|
|
23
|
-
return childPids;
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Recursively finds all descendants of a process
|
|
27
|
-
*/
|
|
28
|
-
export const findProcessTree = (rootPid) => Effect.gen(function* () {
|
|
29
|
-
const allPids = new Set([rootPid]);
|
|
30
|
-
const toProcess = [rootPid];
|
|
31
|
-
while (toProcess.length > 0) {
|
|
32
|
-
const currentPid = toProcess.pop();
|
|
33
|
-
const children = yield* findChildProcesses(currentPid);
|
|
34
|
-
for (const childPid of children) {
|
|
35
|
-
if (!allPids.has(childPid)) {
|
|
36
|
-
allPids.add(childPid);
|
|
37
|
-
toProcess.push(childPid);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return Array.from(allPids);
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* Checks if a process is running
|
|
45
|
-
*/
|
|
46
|
-
export const isProcessRunning = (pid) => Effect.sync(() => {
|
|
47
|
-
try {
|
|
48
|
-
process.kill(pid, 0);
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
/**
|
|
56
|
-
* Kills a process tree with escalating signals
|
|
57
|
-
*/
|
|
58
|
-
export const killProcessTree = (rootPid, options = {}) => Effect.gen(function* () {
|
|
59
|
-
const { timeout = 5000, signals = ['SIGTERM', 'SIGKILL'], includeRoot = true } = options;
|
|
60
|
-
// Find all processes in the tree
|
|
61
|
-
const allPids = yield* findProcessTree(rootPid);
|
|
62
|
-
const pidsToKill = includeRoot ? allPids : allPids.filter((pid) => pid !== rootPid);
|
|
63
|
-
if (pidsToKill.length === 0) {
|
|
64
|
-
return { killedPids: [], failedPids: [] };
|
|
65
|
-
}
|
|
66
|
-
const killedPids = [];
|
|
67
|
-
const failedPids = [];
|
|
68
|
-
// Try each signal with timeout
|
|
69
|
-
for (const signal of signals) {
|
|
70
|
-
// Check which processes are still running and not yet killed
|
|
71
|
-
const stillRunningChecks = yield* Effect.all(pidsToKill
|
|
72
|
-
.filter((pid) => !killedPids.includes(pid))
|
|
73
|
-
.map((pid) => isProcessRunning(pid).pipe(Effect.map((running) => ({ pid, running })))));
|
|
74
|
-
const remainingPids = stillRunningChecks.filter(({ running }) => running).map(({ pid }) => pid);
|
|
75
|
-
if (remainingPids.length === 0)
|
|
76
|
-
break;
|
|
77
|
-
// Send signal to all remaining processes
|
|
78
|
-
for (const pid of remainingPids) {
|
|
79
|
-
yield* Effect.sync(() => {
|
|
80
|
-
try {
|
|
81
|
-
process.kill(pid, signal);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// Process might already be dead, continue
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// Wait for processes to terminate with polling
|
|
89
|
-
const waitStart = Date.now();
|
|
90
|
-
while (Date.now() - waitStart < timeout) {
|
|
91
|
-
const runningChecks = yield* Effect.all(remainingPids.map((pid) => isProcessRunning(pid).pipe(Effect.map((running) => ({ pid, running })))));
|
|
92
|
-
const stillRunning = runningChecks.filter(({ running }) => running).map(({ pid }) => pid);
|
|
93
|
-
if (stillRunning.length === 0) {
|
|
94
|
-
// All processes terminated
|
|
95
|
-
killedPids.push(...remainingPids);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
// Short sleep before checking again
|
|
99
|
-
yield* Effect.sleep('100 millis');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Check final status
|
|
103
|
-
const finalChecks = yield* Effect.all(pidsToKill.map((pid) => isProcessRunning(pid).pipe(Effect.map((running) => ({ pid, running })))));
|
|
104
|
-
for (const { pid, running } of finalChecks) {
|
|
105
|
-
if (!killedPids.includes(pid) && running) {
|
|
106
|
-
failedPids.push(pid);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return { killedPids, failedPids };
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* Finds orphaned processes by name pattern
|
|
113
|
-
*/
|
|
114
|
-
export const findOrphanedProcesses = (namePattern) => Effect.gen(function* () {
|
|
115
|
-
// Find processes that match the pattern and have init (PID 1) as parent
|
|
116
|
-
const result = yield* Command.make('ps', '-eo', 'pid,ppid,comm').pipe(Command.start, Effect.flatMap((command) => command.stdout.pipe(Stream.decodeText('utf8'), Stream.runCollect, Effect.map((chunks) => Array.from(chunks).join('')))), Effect.catchAll(() => Effect.succeed('')));
|
|
117
|
-
if (!result)
|
|
118
|
-
return [];
|
|
119
|
-
const lines = result.split('\n');
|
|
120
|
-
const patternRegex = new RegExp(namePattern);
|
|
121
|
-
const parentRegex = /^\s*(\d+)\s+1\s+/;
|
|
122
|
-
const orphanedPids = lines
|
|
123
|
-
.filter((line) => patternRegex.test(line))
|
|
124
|
-
.map((line) => {
|
|
125
|
-
const match = line.trim().match(parentRegex);
|
|
126
|
-
return match ? Number.parseInt(match[1], 10) : null;
|
|
127
|
-
})
|
|
128
|
-
.filter((pid) => pid !== null);
|
|
129
|
-
return orphanedPids;
|
|
130
|
-
});
|
|
131
|
-
/**
|
|
132
|
-
* Defensive cleanup for orphaned processes matching given patterns.
|
|
133
|
-
*
|
|
134
|
-
* This function provides fallback cleanup for edge cases where normal process
|
|
135
|
-
* termination mechanisms fail (e.g., hard crashes, SIGKILL before cleanup runs,
|
|
136
|
-
* or limitations in synchronous exit handlers). While proper process tree cleanup
|
|
137
|
-
* should prevent orphans in most cases, this serves as a safety net for scenarios
|
|
138
|
-
* where child processes become orphaned despite cleanup efforts.
|
|
139
|
-
*
|
|
140
|
-
* @param processPatterns - Array of process name patterns to search for (e.g., ['wrangler', 'workerd'])
|
|
141
|
-
* @returns Object with arrays of successfully cleaned and failed PIDs
|
|
142
|
-
*/
|
|
143
|
-
export const cleanupOrphanedProcesses = (processPatterns) => Effect.gen(function* () {
|
|
144
|
-
const cleaned = [];
|
|
145
|
-
const failed = [];
|
|
146
|
-
// Find all orphaned processes matching the patterns
|
|
147
|
-
const allOrphanedPids = [];
|
|
148
|
-
const patternCounts = {};
|
|
149
|
-
for (const pattern of processPatterns) {
|
|
150
|
-
const orphaned = yield* findOrphanedProcesses(pattern);
|
|
151
|
-
allOrphanedPids.push(...orphaned);
|
|
152
|
-
patternCounts[pattern] = orphaned.length;
|
|
153
|
-
}
|
|
154
|
-
if (allOrphanedPids.length === 0) {
|
|
155
|
-
return { cleaned, failed };
|
|
156
|
-
}
|
|
157
|
-
const patternSummary = Object.entries(patternCounts)
|
|
158
|
-
.map(([pattern, count]) => `${count} ${pattern}`)
|
|
159
|
-
.join(', ');
|
|
160
|
-
yield* Effect.logInfo(`Found ${allOrphanedPids.length} orphaned processes (${patternSummary}): ${allOrphanedPids.join(', ')}`);
|
|
161
|
-
for (const pid of allOrphanedPids) {
|
|
162
|
-
const result = yield* killProcessTree(pid, {
|
|
163
|
-
timeout: 2000,
|
|
164
|
-
signals: ['SIGTERM', 'SIGKILL'],
|
|
165
|
-
includeRoot: true,
|
|
166
|
-
}).pipe(Effect.orElse(() => Effect.succeed({ killedPids: [], failedPids: [pid] })));
|
|
167
|
-
if (result.failedPids.length === 0) {
|
|
168
|
-
cleaned.push(...result.killedPids);
|
|
169
|
-
yield* Effect.logInfo(`Cleaned up orphaned process tree starting with ${pid} (${result.killedPids.length} processes)`);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
failed.push(pid, ...result.failedPids);
|
|
173
|
-
yield* Effect.logWarning(`Failed to clean up some processes in tree ${pid}: ${result.failedPids.join(', ')}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return { cleaned, failed };
|
|
177
|
-
});
|
|
178
|
-
//# sourceMappingURL=process-tree-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-tree-manager.js","sourceRoot":"","sources":["../../../src/node/WranglerDevServer/process-tree-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAE3G,MAAM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AAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;YAClC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CACnB,kDAAkD,GAAG,KAAK,MAAM,CAAC,UAAU,CAAC,MAAM,aAAa,CAChG,CAAA;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;YACtC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,6CAA6C,GAAG,KAAK,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/G,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC,CAAC,CAAA"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Effect, UnknownError } from '@livestore/utils/effect';
|
|
2
|
-
export declare const startDockerComposeServices: (args: StartDockerComposeServicesArgs) => Effect.Effect<void, UnknownError, never>;
|
|
3
|
-
type StartDockerComposeServicesArgs = {
|
|
4
|
-
composeFilePath?: string;
|
|
5
|
-
cwd: string;
|
|
6
|
-
serviceName?: string;
|
|
7
|
-
waitForLog?: string;
|
|
8
|
-
env?: Record<string, string>;
|
|
9
|
-
healthCheck?: {
|
|
10
|
-
url: string;
|
|
11
|
-
expectedStatus?: number;
|
|
12
|
-
maxAttempts?: number;
|
|
13
|
-
delayMs?: number;
|
|
14
|
-
};
|
|
15
|
-
/** @default false */
|
|
16
|
-
forwardLogs?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare const pullDockerComposeImages: ({ cwd, composeFilePath, }: Pick<StartDockerComposeServicesArgs, "composeFilePath" | "cwd">) => Effect.Effect<void, import("@effect/platform/Error").PlatformError | import("./cmd.ts").CmdError, import("@effect/platform/CommandExecutor").CommandExecutor>;
|
|
19
|
-
/**
|
|
20
|
-
* Starts Docker Compose services for testing with automatic cleanup.
|
|
21
|
-
* Automatically allocates a free port and passes it as EXPOSED_PORT environment variable.
|
|
22
|
-
*
|
|
23
|
-
* @param composeFilePath - Path to docker-compose.yml file (defaults to `${cwd}/docker-compose.yml`)
|
|
24
|
-
* @param cwd - Working directory for Docker Compose commands
|
|
25
|
-
* @param env - Environment variables to pass to the Docker Compose commands (useful for passing ports)
|
|
26
|
-
* @param serviceName - Optional specific service to start (omit to start all)
|
|
27
|
-
* @param waitForLog - Log pattern to wait for before considering services ready
|
|
28
|
-
* @param healthCheck - Health check configuration for waiting until service is ready
|
|
29
|
-
*/
|
|
30
|
-
export declare const startDockerComposeServicesPromise: ({ composeFilePath, cwd, serviceName, waitForLog, healthCheck, env, forwardLogs, }: StartDockerComposeServicesArgs) => Promise<void>;
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=vitest-docker-compose-setup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-docker-compose-setup.d.ts","sourceRoot":"","sources":["../../src/node/vitest-docker-compose-setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG9D,eAAO,MAAM,0BAA0B,GAAI,MAAM,8BAA8B,6CAIvB,CAAA;AAExD,KAAK,8BAA8B,GAAG;IACpC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,WAAW,CAAC,EAAE;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,qBAAqB;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,2BAGrC,IAAI,CAAC,8BAA8B,EAAE,iBAAiB,GAAG,KAAK,CAAC,kKAIb,CAAA;AAErD;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,iCAAiC,GAAU,mFAQrD,8BAA8B,kBA4HhC,CAAA"}
|