Commit b60603a
fix: Bun runtime result capture with MCP integration
🐛 Bug Fix:
- Fixed Bun runtime not returning results when MCP integration enabled
- Issue: wrapCode checked for 'return' anywhere, found it in MCP proxy functions
- Result: Assumed code had top-level return, didn't add one to last expression
- Effect: __result was undefined, no result returned to user
🔧 Solution:
- Changed hasReturnStatement check to hasTopLevelReturn
- Only check last 3 lines for return statements (not entire code)
- Avoids false positives from return statements inside MCP proxy functions
✅ Testing:
- QuickJS: Already working (no regression)
- Bun: Now returns 42, "Hello", {objects}, [arrays], booleans correctly
- All expression types validated
Root cause: Line 276 `trimmedCode.includes('return ')` matched MCP proxy code like:
```js
async store_memory(args) => {
return await __mcpCall(...); // <-- Matched here!
}
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent dab0c15 commit b60603a
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | | - | |
279 | | - | |
| 283 | + | |
| 284 | + | |
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
| |||
0 commit comments