This commit removes extensive debug logging that was added for troubleshooting
SQS compilation worker issues. The logging served its purpose in identifying
and fixing the compilation result transmission problems, but is now removed
to improve performance in production.
Changes:
- Removed verbose SQS message parsing debug logs
- Removed WebSocket transmission debug logs
- Removed compilation processing debug logs
- Kept essential error logging for troubleshooting
- Updated documentation to reflect shared parsing utilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added detailed logging to diagnose why compilation results aren't being sent
back via WebSocket:
- Log all stages of WebSocket sender creation and result transmission
- Check for both compilequeue.events_url and execqueue.events_url configuration
- Create custom property getter to use compilation-specific events URL
- Log result structure and WebSocket connection details
- Enhanced error reporting with full error details
This will help identify whether the issue is in WebSocket configuration,
connection, or result formatting.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Created shared parsing functions that both web handlers and SQS workers can use:
- Added compilation-request-parser.ts with utilities for parsing user arguments,
execution parameters, tools, and filters consistently
- Updated web handler parseRequest() to use shared utilities for final parsing steps
- SQS workers now use the same parsing logic as web handlers for consistency
- Ensures both code paths handle argument splitting, tool processing, and
parameter validation the same way
This provides the foundation for consistent compilation request handling across
different entry points (web API, SQS workers) while maintaining backward
compatibility with existing web handler logic.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed the issue where SQS messages had incorrect parameter mapping by:
- Added convertSqsMessageToParsedRequest() function that properly maps SQS message
structure to the format expected by compile handlers
- Updated doOneCompilation() to use shared parsing logic instead of direct field mapping
- Fixed the parameter structure mismatch where msg.filters should be used for filters
instead of incorrectly passing msg.backendOptions, etc.
- Reused compilation handler patterns from lib/handlers/compile.ts for consistency
This ensures SQS workers use the same parameter structure as the web handlers,
preventing compilation failures due to incorrect option parsing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Identified root cause: Lambda sends 'options' as object instead of string array.
Enhanced debugging to show more of the message content and added defensive fix:
- Increased message logging from 300 to 1000 chars (first) + 500 chars (last)
- Added comprehensive SQS polling debug info
- Added defensive conversion for options object to array
- Extract userArguments string and split into array if available
- Default to empty array if no valid options structure found
This allows compilation to proceed while Lambda can be fixed separately.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Enhance debug logging in SQS compilation queue to diagnose the issue where
SQS messages are being received as indexed character objects instead of
proper JSON objects. Added detailed logging at multiple levels:
- SQS message structure validation
- Raw message body analysis
- JSON parsing diagnostics
- Post-parse object validation
- Property access testing
This will help identify whether the issue is in SQS client configuration,
JSON parsing, or message corruption between parsing and usage.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add info-level logging to show full SQS message content when processing
compilation requests. This helps debug issues where message fields like
'options' might be undefined, causing compilation failures.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add WaitTimeSeconds=20 for SQS long polling (immediate message delivery, efficient empty queue handling)
- Change default poll_interval_ms from 50ms to 1000ms (only applies between messages/errors)
- Add error handling to ensure worker threads continue after failures
- Update comments to explain long polling behavior and performance characteristics
With long polling, response time is < 100ms when messages are available, and up to 20s when queue is empty, providing optimal balance of performance and cost efficiency.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add compilequeue.poll_interval_ms property (default: 50ms)
- Make SQS queue polling interval configurable instead of hardcoded 100ms
- Update documentation to include new configuration property
- Log polling interval on worker startup for debugging
This allows fine-tuning the polling frequency based on workload and latency requirements.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Remove queue producer code (SqsCompileRequester, RemoteCompilationEnvironment)
- Save producer code reference in compilation-queue-producer-reference.md
- Simplify to single SQS queue for both regular and CMake compilations
- Use isCMake flag in messages to distinguish compilation types
- Update worker to poll single queue and determine compilation type from message
- Remove cmake_queue_url configuration property
- Update documentation to reflect Lambda-based message production approach
The producer functionality will be implemented separately in Lambda functions.
Workers now only consume from queues and process compilation requests.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This adds a new worker mode for compilation tasks similar to the existing execution worker architecture:
- Add SQS-based compilation queue infrastructure for regular and CMake compilations
- Implement RemoteCompilationEnvironment for client-side queue interaction
- Add worker startup logic in main.ts to detect and initialize compilation workers
- Create proper message types and serialization for compilation requests
- Implement WebSocket-based result delivery using existing EventsWsSender
- Add configuration properties for compilation worker mode
- Include structured logging and basic metrics for worker operations
- Update documentation with worker mode configuration details
The implementation supports:
- Dual queue system (regular compilation + CMake compilation)
- Configurable number of worker threads per queue type
- Language-aware compiler discovery and execution
- Comprehensive error handling and logging
- Backward compatible with existing compilation API
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
## Summary
- Fixes EBADF error in HeaptrackWrapper by removing redundant file
descriptor close operation
- The net.Socket takes ownership of the FD and closes it during cleanup,
making manual close unnecessary and dangerous
## Root Cause Analysis
The issue occurred in `lib/runtime-tools/heaptrack-wrapper.ts:133` where
the code attempted to manually close a file descriptor that was already
owned by a `net.Socket`. When creating a socket with `new
net.Socket({fd: fd})`, the socket takes ownership of the file descriptor
and closes it during cleanup operations like `resetAndDestroy()`.
Attempting to close the FD again results in:
1. EBADF errors when the FD hasn't been recycled
2. Potentially closing a different resource if the FD has been recycled
by the OS
## Solution
Removed the manual `oldfs.close(fd)` call since the socket handles FD
cleanup automatically. This prevents both the EBADF error and the more
dangerous scenario of closing recycled file descriptors.
## Verification
Created tests to verify that `net.Socket` takes ownership of file
descriptors:
```javascript
// Test confirms that after socket.destroy(), the FD is no longer valid
const fd = fs.openSync(pipePath, O_RDWR | O_NONBLOCK);
const socket = new net.Socket({ fd: fd, readable: true, writable: true });
socket.destroy();
// fs.fstatSync(fd) throws EBADF - confirming FD was closed by socket
```
## Test Plan
- [x] TypeScript compilation passes
- [x] Minimal test suite passes
- [x] Pre-commit hooks pass
- [x] Created unit test to verify net.Socket FD ownership behavior
Fixes COMPILER-EXPLORER-EA7
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
- Removes `rootDirs` so all imports will be relative in the frontend
- Updates (and unifies) imports to be `../types/...` etc instead of
relying on "types" being in the rootDir for the frontend.
- Fixes one type that was being picked up from `lib` in the frontend.
- Adds a precommit hook to check in future
Paves the way to writing _unit_ tests for the frontend for the subset of
the frontend code we can import from `node` (which might be a lot of
it!)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
Fix#7809 and then some:
Stop processing opt-remarks if none were requested,
Make gcc dump remarks to file,
separate opt-file handling to ClangCompiler and GccCompiler,
make DefaultCompiler inherit GccCompiler,
move some tests around.
Resolves#7780.
Basically a follow-up to #7652; the output format of `rustc --help` was
changed to include angle brackets `<` and `>`. This PR updates the
regexes used to parse the help output and adds some tests.
## Summary
- Extracted source line handling logic into a dedicated
`SourceLineHandler` class that consolidates .loc, .stabs, and .6502
directive parsing
- Extracted label processing logic into a `LabelProcessor` class with
methods for finding used labels and filtering
- Created a `ParsingState` class to manage parsing loop state variables
in a centralized way
- Fully integrated all components into the main `AsmParser` class,
replacing the original complex parsing loop
## Changes Made
- **SourceLineHandler**: Unifies `.loc`, `.d2line`, `.cv_loc`, `.dbg`,
`.stabn`, and 6502 debug directive parsing
- **LabelProcessor**: Handles complex label detection, filtering, and
cleanup logic with MIPS/non-MIPS support
- **ParsingState**: Encapsulates state management during parsing
(inNvccCode, inCustomAssembly, etc.)
- **Integration**: All components work together through well-defined
interfaces
## Verification
- ✅ All 1082+ tests pass, including new subclass compatibility tests
from PR #7779
- ✅ All 670+ filter tests pass, confirming exact behavior preservation
- ✅ Added comprehensive unit tests for all new components (32 tests
total)
- ✅ TypeScript compilation and linting pass
- ✅ No performance regression in core functionality
## Bug Fix Discovered
The refactoring inadvertently **fixes issue #7781** - EWAVR label
detection bug:
- **Before**: EWAVR couldn't find labels in usage contexts like `ldi
r16, HIGH(_data)` due to `labelFindFor()` returning definition regex
- **After**: Now correctly uses `identifierFindRe` to find labels in
usage contexts
- Updated tests to reflect the corrected behavior
## Benefits
- Reduced complexity in the main `processAsm` method (from 180+ lines to
more manageable chunks)
- Extracted highly testable, focused components with single
responsibilities
- Eliminated code duplication between source handling methods
- Centralized state management reduces scattered variable handling
- Maintained full backward compatibility and exact behavior
- Fixed EWAVR label detection bug as a side effect
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
## Summary
Fixes unsafe type casting in assembly processing tools that was causing
`TypeError: text.split is not a function` runtime crashes.
## Root Cause Analysis
**COMPILER-EXPLORER-C2N** (57 occurrences) and **COMPILER-EXPLORER-AWW**
(184 occurrences):
The issue stemmed from tools making unsafe assumptions about
`compilationInfo.asm` type:
```typescript
// CompilationInfo.asm type (from types/compilation/compilation.interfaces.ts:168)
asm?: ParsedAsmResultLine[] | string; // "Temp hack until we get all code to agree on type of asm"
```
**The bug sequence:**
1. `base-compiler.ts:3120` converts string assembly to parsed format:
`result.asm = [{text: result.asm}]`
2. Tools unsafely cast back to string: `compilationInfo.asm as string`
3. `AsmParser.processBinaryAsm()` calls `splitLines(asmResult)`
4. If `asm` is actually `ParsedAsmResultLine[]`, `splitLines()` receives
an array
5. `text.split()` fails because arrays don't have `.split()` method
**Affected tools:** osaca-tool, x86to6502-tool, llvm-mca-tool
## Changes
### New Helper Functions in `utils.ts`:
1. **`extractTextLines(asm: string | any[]): string[]`**
- Safely extracts text lines from union types
- Throws descriptive errors for unexpected types (will surface in
Sentry)
2. **`normalizeAsmToString(asm: string | any[] | undefined): string`**
- Centralizes the common pattern of converting union type to string for
parser consumption
- Handles undefined gracefully
### Tool Fixes:
- **Removed unsafe casts**: `compilationInfo.asm as string` →
`normalizeAsmToString(compilationInfo.asm)`
- **Added null checks**: Explicit error handling for missing assembly
data
- **Type safety**: No more runtime type assumptions
## Impact
- Eliminates root cause of `text.split is not a function` errors (241+
occurrences combined)
- Maintains existing functionality - tools continue to work normally
- Better error messages when assembly data is missing
- Centralizes type handling logic for future maintainability
**Note:** The underlying architectural issue (union type "temp hack")
remains, but tools now handle it safely without crashes.
Fixes COMPILER-EXPLORER-C2N
Fixes COMPILER-EXPLORER-AWW
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
## Summary
- Fixes COMPILER-EXPLORER-E53: SyntaxError: Unexpected end of JSON input
- Adds robust error handling for malformed client state URLs
- Prevents Sentry notifications for user-caused errors
## Root Cause
The `extractJsonFromBufferAndInflateIfRequired` function and
`unstoredStateHandler` were not properly handling:
- Invalid base64 data in URLs
- Corrupted or malformed JSON after base64 decoding
- Empty JSON strings
This caused uncaught `SyntaxError` exceptions that were being sent to
Sentry as internal server errors.
## Changes
- Added proper error handling for base64 decoding failures
- Added validation for empty JSON strings before parsing
- Changed logging from `warn` to `debug` since this represents user
error
- Removed Sentry capture for malformed URLs to reduce noise
- Return 400 Bad Request instead of 500 Internal Server Error
## Test Plan
- [x] TypeScript compilation passes
- [x] All existing tests pass
- [x] Manual testing with malformed URLs returns 400 instead of 500
- [x] No Sentry errors generated for user-caused malformed URLs
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
## Summary
- Fixes syntax highlighting issue where Rust hex literals with
underscores after hex letters (like `0x01_02_0a_0b`) would lose
highlighting after the underscore
- Created custom Rust language mode (`rustp`) that patches Monaco's
built-in tokenizer
- Filed upstream issue with Monaco Editor:
https://github.com/microsoft/monaco-editor/issues/4917
## Test plan
- [x] Verified fix works locally with test cases like `0x01_02_0a_0b`,
`0xFF_AA_BB_CC`, etc.
- [x] Confirmed all existing tests pass
- [x] Checked that TypeScript compilation and linting pass
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
This PR fixes the LLVM IR output for the Mojo compiler integration,
ensuring the LLVM IR panel works correctly and no longer shows "Internal
error; unable to open output path" errors.