Skip to content

Conversation

lthibault
Copy link
Contributor

@lthibault lthibault commented Sep 25, 2025

⚠️ Merge after #26

Problem: Async Proc mode allowed concurrent message processing, causing race conditions and message ordering issues.

Solution: Added semaphore-based concurrency control to ensure messages are processed sequentially.

Key Changes

  • Add semaphore to Proc struct (limit: 1)
  • Remove semaphore from Endpoint struct
  • Acquire/release semaphore in ProcessMessage for async mode
  • Add IPFS filesystem mounting support (/ipfs, /ipns, /ipld)

Impact

  • ✅ Eliminates race conditions in message processing
  • ✅ Maintains proper message order
  • ✅ Adds IPFS filesystem capabilities

- Update ProcessMessage to accept method parameter for dynamic export invocation
- Add method normalization (empty string defaults to 'poll')
- Add proper error handling for unknown methods with stream reset
- Update all test calls to include method parameter
- Maintain backward compatibility with existing code
- Switch from SetStreamHandler to SetStreamHandlerMatch
- Add protocol matching for both base protocol and method suffix
- Extract method from protocol string (/ww/0.1.0/<proc-id>/<method>)
- Update logging to include method information
- Maintain backward compatibility for existing clients
- Change method from flag to positional argument (final argument)
- Update ArgsUsage to <peer> <proc> [method]
- Add argument validation for 2-3 arguments
- Update protocol construction to include method suffix when specified
- Enhance connection banner to show method being used
- Update examples in help text
- Change exported function from 'poll' to 'echo'
- Update function name and comments accordingly
- This demonstrates the named export functionality
- Rebuild main.wasm with updated echo export function
- Binary now exports 'echo' instead of 'poll' function
- Update tests to use 'echo' function instead of 'poll' to match WASM module exports
- Add Reset() expectations to mock streams to handle function not found cases
- Fix TestProc_Integration_WithRealWasm, TestProc_Poll_WithGomock, TestEcho_Asynchronous, and TestEcho_RepeatedAsync
- All tests now pass successfully
- Add system/ipfs.go with complete fs.FS interface implementation
- Add system/ipfs_test.go with comprehensive test coverage
- Support directory traversal, file reading, and sub-filesystem creation
- Integrate with IPFS UnixFS for distributed file access
- Add github.com/pkg/errors dependency for error handling

This restores the IPFS filesystem functionality that was previously
removed, enabling guest filesystem access to IPFS content.
@lthibault lthibault requested a review from mikelsr September 25, 2025 23:22
@lthibault lthibault self-assigned this Sep 25, 2025
@lthibault lthibault added bug Something isn't working enhancement New feature or request labels Sep 25, 2025
- Replace require.NoError with t.Skipf for IPFS connection errors
- Tests now gracefully skip instead of failing when IPFS is unavailable
- Improves test suite robustness in environments without IPFS
- Add semaphore to Proc struct for concurrent access control
- Remove semaphore from Endpoint struct (moved to Proc)
- Add semaphore acquisition/release in ProcessMessage for async mode
- Ensures messages are processed sequentially to maintain order
- Add IPFS field to ProcConfig for filesystem mounting
- Add NewFSConfig method to mount IPFS filesystem at /ipfs, /ipns, /ipld paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant