Problem
surf js "expression" always prints "undefined" regardless of the expression. Even simple literals like surf js "1 + 1" return "undefined".
Root cause: The EXECUTE_JAVASCRIPT handler wraps user code in (async () => { 'use strict'; <code> })(). This async IIFE never returns a value because there's no return statement for the last expression.
Current workaround
surf js 'console.log("RESULT:" + document.cookie)'
surf console | grep RESULT
Proposed fix
Auto-detect single expressions and add return to make them evaluate like a REPL. Multi-statement code continues to work as-is.
# Should work:
$ surf js "1 + 1"
2
$ surf js "document.title"
"My Page Title"
$ surf js "document.querySelectorAll('button').length"
3
Severity
High — forces workarounds on every JS evaluation in AI agent workflows.
Problem
surf js "expression"always prints"undefined"regardless of the expression. Even simple literals likesurf js "1 + 1"return"undefined".Root cause: The EXECUTE_JAVASCRIPT handler wraps user code in
(async () => { 'use strict'; <code> })(). This async IIFE never returns a value because there's noreturnstatement for the last expression.Current workaround
Proposed fix
Auto-detect single expressions and add
returnto make them evaluate like a REPL. Multi-statement code continues to work as-is.Severity
High — forces workarounds on every JS evaluation in AI agent workflows.