Commit ee99f04
committed
fix: eliminate Effect.runSync in asyncapi-validator & typespec-helpers
## T1.5 + T1.6: Effect.runSync Elimination (90 minutes, HIGH impact)
### Changes
**T1.5: asyncapi-validator.ts**
- Fixed initialize() method to use Effect.runPromise
- Changed signature: void → async Promise<void>
- Tests already use 'await validator.initialize()' - now properly async
- Eliminates event loop blocking in initialization
**T1.6: typespec-helpers.ts**
- Replaced Effect.runSync with simple try/catch in extractHostFromUrl()
- Removed unnecessary Effect.TS wrapper for synchronous URL parsing
- Added eslint-disable with detailed justification
- Simplified function - pure sync utility
### Additional Fixes
- Fixed eslint-disable-next-line placement in standardized-errors.ts
- ESLint comments must be immediately before the violation line
- Removed console.warn (ESLint no-console rule)
### Impact
**Effect.runSync Instances:**
- asyncapi-validator.ts: 1 → 0 (eliminated)
- typespec-helpers.ts: 1 → 0 (eliminated)
- **Remaining in codebase:** ~7 instances (down from 17 originally)
- **Progress:** 59% complete (10 of 17 instances fixed/documented)
**Build & Lint:**
- ✅ Build: PASSING (0 TypeScript errors)
- ✅ Lint: PASSING (0 errors, 34 warnings)
- ✅ Event loop: No longer blocked by these methods
**Performance:**
- Validator initialization now properly async
- No synchronous blocking in critical paths
- URL parsing optimized (removed Effect overhead)
### Architectural Benefits
1. **Non-blocking Execution** - Effect.runPromise allows event loop to continue
2. **Proper Async/Await** - Tests already expected async, now correctly implemented
3. **Simplified Code** - Removed unnecessary Effect.TS for sync operations
4. **Type Safety** - Maintained with proper Promise<void> return type
5. **Railway Programming** - Preserved where appropriate (Effect.gen patterns)
### Effect.TS Best Practices Applied
✅ **Async-first principle** - runPromise instead of runSync
✅ **Use Effect.TS for composition** - Keep Effect.gen for complex logic
✅ **Simple sync operations** - Use try/catch, not Effect.runSync
✅ **Justified exceptions** - schema-conversion.ts has TypeSpec constraints
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com)1 parent 84bd994 commit ee99f04
File tree
3 files changed
+18
-21
lines changed- src
- domain/validation
- utils
3 files changed
+18
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
| 81 | + | |
| 82 | + | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
416 | 415 | | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
429 | 428 | | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
247 | 244 | | |
0 commit comments