Frontmatter
| id | 8207 |
| title | ai.Client: Enhance handleRequest to support sync and async execution |
| state | Closed |
| labels | enhancementai |
| assignees | tobiu |
| createdAt | Dec 30, 2025, 12:59 AM |
| updatedAt | Dec 30, 2025, 1:12 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8207 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 8169 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 30, 2025, 1:12 AM |
ai.Client: Enhance handleRequest to support sync and async execution
tobiu added parent issue #8169 on Dec 30, 2025, 12:59 AM
tobiu assigned to @tobiu on Dec 30, 2025, 1:00 AM

tobiu
Dec 30, 2025, 1:11 AM
Input from Gemini:
✦ I have implemented the enhancements to
handleRequestwith a slight variation from the original proposal to better align with the existingonSocketMessageerror handling architecture.Implementation Details:
- Context Preservation: Explicitly used
.call(service, params)when invoking methods to ensure theserviceinstance context is maintained.- Sync/Async Support: Added checks for both
Neo.isFunctionandNeo.isPromiseto handle synchronous and asynchronous returns correctly.- Error Handling: Retained the existing
try...catchblock inonSocketMessageas the central error handling mechanism, rather than moving it insidehandleRequest.handleRequestsimply returns the result or promise, allowingonSocketMessageto await it and catch any rejections/errors to send the appropriate JSON-RPC error response.
tobiu closed this issue on Dec 30, 2025, 1:12 AM
Refactor
src/ai/Client.mjs=>handleRequest()to match the execution pattern insrc/worker/mixin/RemoteMethodAccess.mjs.Currently,
handleRequestimplicitly assumes async execution. We should explicitly check if the result is a Promise.Requirements:
handleRequestto execute the service method.Neo.isPromise()..then()and.catch()handlers.