@livestore/utils-dev 0.0.0-snapshot-1c345a0e6695466bdc7c4483444e7b3513620261 → 0.0.0-snapshot-92c31f56117b4fd377b66f55163ed565795c5e4c

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.
Files changed (72) hide show
  1. package/dist/.tsbuildinfo.json +1 -1
  2. package/dist/node/DockerComposeService/DockerComposeService.d.ts +48 -0
  3. package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -0
  4. package/dist/node/DockerComposeService/DockerComposeService.js +107 -0
  5. package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -0
  6. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts +2 -0
  7. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts.map +1 -0
  8. package/dist/node/DockerComposeService/DockerComposeService.test.js +64 -0
  9. package/dist/node/DockerComposeService/DockerComposeService.test.js.map +1 -0
  10. package/dist/node/FileLogger.d.ts +14 -0
  11. package/dist/node/FileLogger.d.ts.map +1 -0
  12. package/dist/node/FileLogger.js +151 -0
  13. package/dist/node/FileLogger.js.map +1 -0
  14. package/dist/node/WranglerDevServer/WranglerDevServer.d.ts +51 -0
  15. package/dist/node/WranglerDevServer/WranglerDevServer.d.ts.map +1 -0
  16. package/dist/node/WranglerDevServer/WranglerDevServer.js +102 -0
  17. package/dist/node/WranglerDevServer/WranglerDevServer.js.map +1 -0
  18. package/dist/node/WranglerDevServer/WranglerDevServer.test.d.ts +2 -0
  19. package/dist/node/WranglerDevServer/WranglerDevServer.test.d.ts.map +1 -0
  20. package/dist/node/WranglerDevServer/WranglerDevServer.test.js +186 -0
  21. package/dist/node/WranglerDevServer/WranglerDevServer.test.js.map +1 -0
  22. package/dist/node/WranglerDevServer/fixtures/cf-worker.d.ts +8 -0
  23. package/dist/node/WranglerDevServer/fixtures/cf-worker.d.ts.map +1 -0
  24. package/dist/node/WranglerDevServer/fixtures/cf-worker.js +11 -0
  25. package/dist/node/WranglerDevServer/fixtures/cf-worker.js.map +1 -0
  26. package/dist/node/WranglerDevServer/process-tree-manager.d.ts +55 -0
  27. package/dist/node/WranglerDevServer/process-tree-manager.d.ts.map +1 -0
  28. package/dist/node/WranglerDevServer/process-tree-manager.js +178 -0
  29. package/dist/node/WranglerDevServer/process-tree-manager.js.map +1 -0
  30. package/dist/node/cmd.d.ts +27 -0
  31. package/dist/node/cmd.d.ts.map +1 -0
  32. package/dist/node/cmd.js +55 -0
  33. package/dist/node/cmd.js.map +1 -0
  34. package/dist/node/mod.d.ts +7 -13
  35. package/dist/node/mod.d.ts.map +1 -1
  36. package/dist/node/mod.js +22 -37
  37. package/dist/node/mod.js.map +1 -1
  38. package/dist/node-vitest/Vitest.d.ts +52 -0
  39. package/dist/node-vitest/Vitest.d.ts.map +1 -0
  40. package/dist/node-vitest/Vitest.js +98 -0
  41. package/dist/node-vitest/Vitest.js.map +1 -0
  42. package/dist/node-vitest/Vitest.test.d.ts +2 -0
  43. package/dist/node-vitest/Vitest.test.d.ts.map +1 -0
  44. package/dist/node-vitest/Vitest.test.js +59 -0
  45. package/dist/node-vitest/Vitest.test.js.map +1 -0
  46. package/dist/node-vitest/global.d.ts +2 -0
  47. package/dist/node-vitest/global.d.ts.map +1 -0
  48. package/dist/node-vitest/{polyfill.js → global.js} +1 -1
  49. package/dist/node-vitest/global.js.map +1 -0
  50. package/dist/node-vitest/mod.d.ts +2 -1
  51. package/dist/node-vitest/mod.d.ts.map +1 -1
  52. package/dist/node-vitest/mod.js +2 -1
  53. package/dist/node-vitest/mod.js.map +1 -1
  54. package/package.json +16 -23
  55. package/src/node/DockerComposeService/DockerComposeService.test.ts +91 -0
  56. package/src/node/DockerComposeService/DockerComposeService.ts +252 -0
  57. package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +4 -0
  58. package/src/node/FileLogger.ts +206 -0
  59. package/src/node/WranglerDevServer/WranglerDevServer.test.ts +268 -0
  60. package/src/node/WranglerDevServer/WranglerDevServer.ts +206 -0
  61. package/src/node/WranglerDevServer/fixtures/cf-worker.ts +11 -0
  62. package/src/node/WranglerDevServer/fixtures/wrangler.toml +11 -0
  63. package/src/node/WranglerDevServer/process-tree-manager.ts +263 -0
  64. package/src/node/cmd.ts +99 -0
  65. package/src/node/mod.ts +39 -77
  66. package/src/node-vitest/Vitest.test.ts +101 -0
  67. package/src/node-vitest/Vitest.ts +221 -0
  68. package/src/node-vitest/mod.ts +3 -1
  69. package/dist/node-vitest/polyfill.d.ts +0 -2
  70. package/dist/node-vitest/polyfill.d.ts.map +0 -1
  71. package/dist/node-vitest/polyfill.js.map +0 -1
  72. /package/src/node-vitest/{polyfill.ts → global.ts} +0 -0
@@ -0,0 +1,268 @@
1
+ import { Effect, Exit, 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 {
6
+ type StartWranglerDevServerArgs,
7
+ WranglerDevServerError,
8
+ WranglerDevServerService,
9
+ } from './WranglerDevServer.ts'
10
+
11
+ const testTimeout = 60_000
12
+
13
+ const withTestCtx = Vitest.makeWithTestCtx({
14
+ timeout: testTimeout,
15
+ makeLayer: () => PlatformNode.NodeContext.layer,
16
+ })
17
+
18
+ const WranglerDevServerTest = (args: Partial<StartWranglerDevServerArgs> = {}) =>
19
+ WranglerDevServerService.Default({
20
+ cwd: `${import.meta.dirname}/fixtures`,
21
+ ...args,
22
+ })
23
+
24
+ Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
25
+ Vitest.describe('Basic Operations', () => {
26
+ const withBasicTest = (args: Partial<StartWranglerDevServerArgs> = {}) =>
27
+ Vitest.makeWithTestCtx({
28
+ timeout: testTimeout,
29
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
30
+ })
31
+
32
+ Vitest.scopedLive('should start wrangler dev server and return port', (test) =>
33
+ Effect.gen(function* () {
34
+ const server = yield* WranglerDevServerService
35
+
36
+ expect(server.port).toBeGreaterThan(0)
37
+ expect(server.url).toMatch(/http:\/\/localhost:\d+/)
38
+ expect(typeof server.processId).toBe('number')
39
+ expect(server.processId).toBeGreaterThan(0)
40
+ }).pipe(withBasicTest()(test)),
41
+ )
42
+
43
+ Vitest.scopedLive('should use specified port when provided', (test) =>
44
+ Effect.gen(function* () {
45
+ const server = yield* WranglerDevServerService
46
+
47
+ expect(server.port).toBe(54443)
48
+ expect(server.url).toBe(`http://localhost:54443`)
49
+ }).pipe(withBasicTest({ port: 54443 })(test)),
50
+ )
51
+ })
52
+
53
+ Vitest.describe('Resource Management', () => {
54
+ Vitest.scopedLive('should cleanup processes on scope close', (test) =>
55
+ Effect.gen(function* () {
56
+ let processId: number | undefined
57
+
58
+ // Create a separate scope for the server
59
+ const serverScope = yield* Scope.make()
60
+
61
+ const server = yield* Effect.provide(
62
+ WranglerDevServerService,
63
+ WranglerDevServerTest().pipe(Layer.provide(PlatformNode.NodeContext.layer)),
64
+ ).pipe(Scope.extend(serverScope))
65
+
66
+ processId = server.processId
67
+ expect(processId).toBeGreaterThan(0)
68
+ expect(server.port).toBeGreaterThan(0)
69
+ expect(server.url).toMatch(/http:\/\/localhost:\d+/)
70
+
71
+ // Close scope to trigger cleanup
72
+ yield* Scope.close(serverScope, Exit.succeed(void 0))
73
+
74
+ // Wait for cleanup to complete
75
+ yield* Effect.sleep('2 seconds')
76
+
77
+ // Verify process is terminated
78
+ const isRunning2 = yield* Effect.promise(() => {
79
+ try {
80
+ process.kill(processId!, 0)
81
+ return Promise.resolve(true)
82
+ } catch {
83
+ return Promise.resolve(false)
84
+ }
85
+ })
86
+ expect(isRunning2).toBe(false)
87
+ }).pipe(withTestCtx(test)),
88
+ )
89
+
90
+ Vitest.scopedLive('should handle interruption with fast cleanup', (test) =>
91
+ Effect.gen(function* () {
92
+ let processId: number | undefined
93
+
94
+ const fiber = yield* Effect.fork(
95
+ Effect.provide(
96
+ Effect.gen(function* () {
97
+ const server = yield* WranglerDevServerService
98
+ processId = server.processId
99
+ yield* Effect.sleep('30 seconds') // Keep running
100
+ return server
101
+ }),
102
+ WranglerDevServerTest().pipe(Layer.provide(PlatformNode.NodeContext.layer)),
103
+ ),
104
+ )
105
+
106
+ // Wait for server to start
107
+ yield* Effect.sleep('3 seconds')
108
+
109
+ expect(processId).toBeGreaterThan(0)
110
+
111
+ // Interrupt and measure cleanup time
112
+ const start = Date.now()
113
+ yield* Fiber.interrupt(fiber)
114
+ const elapsed = Date.now() - start
115
+
116
+ // Should use fast cleanup (500ms timeout) + some overhead
117
+ expect(elapsed).toBeLessThan(1500) // Allow some overhead
118
+
119
+ // Wait for cleanup to complete
120
+ yield* Effect.sleep('1 second')
121
+
122
+ // Verify process is terminated
123
+ const isRunningAfter = yield* Effect.promise(() => {
124
+ try {
125
+ process.kill(processId!, 0)
126
+ return Promise.resolve(true)
127
+ } catch {
128
+ return Promise.resolve(false)
129
+ }
130
+ })
131
+ expect(isRunningAfter).toBe(false)
132
+ }).pipe(withTestCtx(test)),
133
+ )
134
+ })
135
+
136
+ Vitest.describe('Error Handling', () => {
137
+ const withErrorTest = (args: Partial<StartWranglerDevServerArgs> = {}) =>
138
+ Vitest.makeWithTestCtx({
139
+ timeout: testTimeout,
140
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
141
+ })
142
+
143
+ Vitest.scopedLive('should handle missing wrangler.toml', (test) =>
144
+ Effect.gen(function* () {
145
+ // Since Wrangler can work without a config file, let's test with a truly invalid scenario
146
+ const result = yield* WranglerDevServerService.pipe(Effect.either)
147
+
148
+ // Note: Wrangler might still succeed even with /dev/null, so this test
149
+ // verifies our implementation handles the case properly, whether it succeeds or fails
150
+ expect(['Left', 'Right']).toContain(result._tag)
151
+
152
+ if (result._tag === 'Left') {
153
+ // If it fails, it should be a wrapped error
154
+ expect(result.left).toBeInstanceOf(WranglerDevServerError)
155
+ } else {
156
+ // If it succeeds, the server should be properly configured
157
+ expect(result.right.port).toBeGreaterThan(0)
158
+ }
159
+ }).pipe(withErrorTest({ cwd: '/tmp', wranglerConfigPath: '/dev/null' })(test)),
160
+ )
161
+
162
+ Vitest.scopedLive('should handle invalid working directory', (test) =>
163
+ Effect.gen(function* () {
164
+ const result = yield* WranglerDevServerService.pipe(
165
+ Effect.provide(
166
+ WranglerDevServerTest({
167
+ cwd: '/completely/nonexistent/directory',
168
+ }).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
169
+ ),
170
+ Effect.either,
171
+ )
172
+
173
+ expect(result._tag).toBe('Left')
174
+ if (result._tag === 'Left') {
175
+ expect(result.left).toBeInstanceOf(WranglerDevServerError)
176
+ }
177
+ }).pipe(Vitest.withTestCtx(test)),
178
+ )
179
+
180
+ Vitest.scopedLive('should timeout if server fails to start', (test) =>
181
+ Effect.gen(function* () {
182
+ // Create a command that will never output "Ready on"
183
+ const result = yield* WranglerDevServerService.pipe(
184
+ // Override the timeout for this test to be shorter
185
+ Effect.timeout('5 seconds'),
186
+ Effect.either,
187
+ )
188
+
189
+ // This might succeed or fail depending on actual wrangler behavior
190
+ // The main point is testing timeout functionality
191
+ expect(['Left', 'Right']).toContain(result._tag)
192
+ }).pipe(withErrorTest()(test)),
193
+ )
194
+ })
195
+
196
+ Vitest.describe('Process Tree Cleanup', () => {
197
+ const withCleanupTest = (args: Partial<StartWranglerDevServerArgs> = {}) =>
198
+ Vitest.makeWithTestCtx({
199
+ timeout: testTimeout,
200
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
201
+ })
202
+
203
+ Vitest.scopedLive('should clean up child workerd processes', (test) =>
204
+ Effect.gen(function* () {
205
+ let processId: number | undefined
206
+
207
+ const server = yield* WranglerDevServerService
208
+ processId = server.processId
209
+
210
+ // Wait for wrangler to spawn workerd children
211
+ yield* Effect.sleep('3 seconds')
212
+
213
+ // Find any child processes (workerd)
214
+ const children = yield* Effect.promise(async () => {
215
+ const { exec } = require('node:child_process')
216
+ const { promisify } = require('node:util')
217
+ const execAsync = promisify(exec)
218
+
219
+ try {
220
+ if (!processId) throw new Error('processId is undefined')
221
+ const { stdout } = await execAsync(`ps -o pid,ppid -ax | grep -E "^\\s*[0-9]+\\s+${processId}\\s*$"`)
222
+ return stdout
223
+ .trim()
224
+ .split('\n')
225
+ .map((line: string) => {
226
+ const match = line.trim().match(/^\s*(\d+)\s+\d+\s*$/)
227
+ return match?.[1] ? Number.parseInt(match[1], 10) : null
228
+ })
229
+ .filter((pid: number | null): pid is number => pid !== null)
230
+ } catch {
231
+ return []
232
+ }
233
+ })
234
+
235
+ console.log(`Found ${children.length} child processes:`, children)
236
+
237
+ // The scope will close here and should clean up all processes
238
+ }).pipe(withCleanupTest()(test)),
239
+ )
240
+ })
241
+
242
+ Vitest.describe('Service Pattern', () => {
243
+ const withServiceTest = (args: Partial<StartWranglerDevServerArgs> = {}) =>
244
+ Vitest.makeWithTestCtx({
245
+ timeout: testTimeout,
246
+ makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeContext.layer)),
247
+ })
248
+
249
+ Vitest.scopedLive('should work with service pattern', (test) =>
250
+ Effect.gen(function* () {
251
+ const server = yield* WranglerDevServerService
252
+
253
+ expect(server.port).toBeGreaterThan(0)
254
+ expect(server.url).toMatch(/http:\/\/localhost:\d+/)
255
+ expect(server.processId).toBeGreaterThan(0)
256
+ }).pipe(withServiceTest()(test)),
257
+ )
258
+
259
+ Vitest.scopedLive('should work with custom port via service', (test) =>
260
+ Effect.gen(function* () {
261
+ const server = yield* WranglerDevServerService
262
+
263
+ expect(server.port).toBe(54444)
264
+ expect(server.url).toBe('http://localhost:54444')
265
+ }).pipe(withServiceTest({ port: 54444 })(test)),
266
+ )
267
+ })
268
+ })
@@ -0,0 +1,206 @@
1
+ import * as path from 'node:path'
2
+
3
+ import { Command, Effect, Exit, type PlatformError, Schema, Stream } from '@livestore/utils/effect'
4
+ import { getFreePort } from '@livestore/utils/node'
5
+ import { cleanupOrphanedProcesses, killProcessTree } from './process-tree-manager.ts'
6
+
7
+ /**
8
+ * Error type for WranglerDevServer operations
9
+ */
10
+ export class WranglerDevServerError extends Schema.TaggedError<WranglerDevServerError>()('WranglerDevServerError', {
11
+ cause: Schema.Unknown,
12
+ message: Schema.String,
13
+ port: Schema.Number,
14
+ }) {}
15
+
16
+ /**
17
+ * WranglerDevServer instance interface
18
+ */
19
+ export interface WranglerDevServer {
20
+ readonly port: number
21
+ readonly url: string
22
+ readonly processId: number
23
+ }
24
+
25
+ /**
26
+ * Configuration for starting WranglerDevServer
27
+ */
28
+ export interface StartWranglerDevServerArgs {
29
+ wranglerConfigPath?: string
30
+ cwd: string
31
+ port?: number
32
+ /** @default false */
33
+ showLogs?: boolean
34
+ }
35
+
36
+ /**
37
+ * WranglerDevServer as an Effect.Service.
38
+ *
39
+ * This service provides the WranglerDevServer properties and can be accessed
40
+ * directly to get port, url, and processId.
41
+ *
42
+ * TODO: Allow for config to be passed in via code instead of `wrangler.toml` file
43
+ * (would need to be placed in temporary file as wrangler only accepts files as config)
44
+ */
45
+ export class WranglerDevServerService extends Effect.Service<WranglerDevServerService>()('WranglerDevServerService', {
46
+ scoped: (args: StartWranglerDevServerArgs) =>
47
+ Effect.gen(function* () {
48
+ const showLogs = args.showLogs ?? false
49
+
50
+ // Clean up any orphaned processes before starting (defensive cleanup)
51
+ yield* cleanupOrphanedProcesses(['wrangler', 'workerd']).pipe(
52
+ Effect.tap((result) =>
53
+ showLogs && (result.cleaned.length > 0 || result.failed.length > 0)
54
+ ? Effect.logInfo(`Cleanup result: ${result.cleaned.length} cleaned, ${result.failed.length} failed`)
55
+ : Effect.void,
56
+ ),
57
+ Effect.ignore, // Don't fail startup if cleanup fails
58
+ )
59
+
60
+ // Allocate port
61
+ const port =
62
+ args.port ??
63
+ (yield* getFreePort.pipe(
64
+ Effect.mapError(
65
+ (cause) => new WranglerDevServerError({ cause, message: 'Failed to get free port', port: -1 }),
66
+ ),
67
+ ))
68
+
69
+ yield* Effect.annotateCurrentSpan({ port })
70
+
71
+ // Resolve config path
72
+ const configPath = path.resolve(args.wranglerConfigPath ?? path.join(args.cwd, 'wrangler.toml'))
73
+
74
+ // Start wrangler process using Effect Command
75
+ const process = yield* Command.make(
76
+ 'bunx',
77
+ 'wrangler',
78
+ 'dev',
79
+ '--port',
80
+ port.toString(),
81
+ '--config',
82
+ configPath,
83
+ ).pipe(
84
+ Command.workingDirectory(args.cwd),
85
+ Command.stdout('pipe'),
86
+ Command.stderr('pipe'),
87
+ Command.start,
88
+ Effect.catchAllCause(
89
+ (error) =>
90
+ new WranglerDevServerError({
91
+ cause: error,
92
+ message: `Failed to start wrangler process in directory: ${args.cwd}`,
93
+ port,
94
+ }),
95
+ ),
96
+ Effect.withSpan('WranglerDevServerService:startProcess'),
97
+ )
98
+
99
+ if (showLogs) {
100
+ yield* process.stderr.pipe(
101
+ Stream.decodeText('utf8'),
102
+ Stream.tapLogWithLabel('wrangler:stderr'),
103
+ Stream.runDrain,
104
+ Effect.forkScoped,
105
+ )
106
+ }
107
+
108
+ const processId = process.pid
109
+
110
+ // We need to keep the `stdout` stream open, as we drain it in the waitForReady function
111
+ // Otherwise we'll get a EPIPE error
112
+ const stdout = yield* Stream.broadcastDynamic(process.stdout, 100)
113
+
114
+ // Register cleanup finalizer with intelligent timeout handling
115
+ yield* Effect.addFinalizer((exit) =>
116
+ Effect.gen(function* () {
117
+ const isInterrupted = Exit.isInterrupted(exit)
118
+ if (showLogs) {
119
+ yield* Effect.logDebug(`Cleaning up wrangler process ${processId}, interrupted: ${isInterrupted}`)
120
+ }
121
+ // yield* Effect.logDebug(`Cleaning up wrangler process ${processId}, interrupted: ${isInterrupted}`)
122
+
123
+ // Check if process is still running
124
+ const isRunning = yield* process.isRunning
125
+
126
+ if (isRunning) {
127
+ // Use our enhanced process tree cleanup
128
+ yield* killProcessTree(processId, {
129
+ timeout: isInterrupted ? 500 : 3000, // Fast cleanup on interruption
130
+ signals: ['SIGTERM', 'SIGKILL'],
131
+ includeRoot: true,
132
+ }).pipe(
133
+ Effect.tap((result) =>
134
+ showLogs
135
+ ? Effect.logDebug(
136
+ `Cleaned up ${result.killedPids.length} processes, ${result.failedPids.length} failed`,
137
+ )
138
+ : Effect.void,
139
+ ),
140
+ Effect.mapError(
141
+ (error) =>
142
+ new WranglerDevServerError({
143
+ cause: error,
144
+ message: `Failed to kill process tree for PID ${processId}`,
145
+ port: 0,
146
+ }),
147
+ ),
148
+ Effect.ignore, // Don't fail the finalizer if cleanup has issues
149
+ )
150
+
151
+ // Also kill the command process handle
152
+ yield* process.kill()
153
+ } else if (showLogs) {
154
+ yield* Effect.logDebug(`Process ${processId} already terminated`)
155
+ }
156
+ }).pipe(
157
+ Effect.timeout('5 seconds'), // Don't let cleanup hang forever
158
+ Effect.ignoreLogged,
159
+ ),
160
+ )
161
+
162
+ // Wait for server to be ready
163
+ yield* waitForReady({ stdout, showLogs })
164
+
165
+ if (showLogs) {
166
+ yield* Effect.logDebug(`Wrangler dev server ready on port ${port}`)
167
+ }
168
+
169
+ return {
170
+ port,
171
+ url: `http://localhost:${port}`,
172
+ processId,
173
+ } satisfies WranglerDevServer
174
+ }).pipe(
175
+ Effect.withSpan('WranglerDevServerService', {
176
+ attributes: { port: args.port ?? 'auto', cwd: args.cwd },
177
+ }),
178
+ ),
179
+ }) {}
180
+
181
+ /**
182
+ * Waits for Wrangler server to be ready by monitoring stdout for "Ready on" message
183
+ */
184
+ const waitForReady = ({
185
+ stdout,
186
+ showLogs,
187
+ }: {
188
+ stdout: Stream.Stream<Uint8Array, PlatformError.PlatformError, never>
189
+ showLogs: boolean
190
+ }): Effect.Effect<void, WranglerDevServerError, never> =>
191
+ stdout.pipe(
192
+ Stream.decodeText('utf8'),
193
+ Stream.splitLines,
194
+ Stream.tap((line) => (showLogs ? Effect.logDebug(`[wrangler] ${line}`) : Effect.void)),
195
+ Stream.takeUntil((line) => line.includes('Ready on')),
196
+ Stream.runDrain,
197
+ Effect.timeout('30 seconds'),
198
+ Effect.mapError(
199
+ (error) =>
200
+ new WranglerDevServerError({
201
+ cause: error,
202
+ message: 'Wrangler server failed to start within timeout',
203
+ port: 0,
204
+ }),
205
+ ),
206
+ )
@@ -0,0 +1,11 @@
1
+ export default {
2
+ async fetch(_request: Request): Promise<Response> {
3
+ return new Response('Hello from Wrangler Dev Server test worker!')
4
+ },
5
+ }
6
+
7
+ export class TestDO {
8
+ async fetch(_request: Request): Promise<Response> {
9
+ return new Response('Hello from Test Durable Object!')
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ name = "wrangler-dev-server-test"
2
+ main = "./cf-worker.ts"
3
+ compatibility_date = "2024-05-12"
4
+
5
+ [[durable_objects.bindings]]
6
+ name = "TEST_DO"
7
+ class_name = "TestDO"
8
+
9
+ [[migrations]]
10
+ tag = "v1"
11
+ new_sqlite_classes = ["TestDO"]