File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
agent-server/nodejs/src/lib Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1254,9 +1254,29 @@ export class BrowserAgentServer extends EventEmitter {
12541254 } ) ;
12551255 }
12561256
1257+ // Extract value from CDP RemoteObject
1258+ // CDP returns RemoteObject with structure: {type: 'string', value: 'foo'}
1259+ // For undefined/null, CDP returns: {type: 'undefined'} or {type: 'null', value: null}
1260+ // We need to check if 'value' property exists, not if it's undefined
1261+ let extractedResult ;
1262+ if ( result . result ) {
1263+ if ( 'value' in result . result ) {
1264+ // RemoteObject has a value field - extract it
1265+ extractedResult = result . result . value ;
1266+ } else if ( result . result . type === 'undefined' ) {
1267+ // Special case: undefined has no value field
1268+ extractedResult = undefined ;
1269+ } else {
1270+ // For objects/functions without returnByValue, return the whole RemoteObject
1271+ extractedResult = result . result ;
1272+ }
1273+ } else {
1274+ extractedResult = result . result ;
1275+ }
1276+
12571277 return {
12581278 tabId,
1259- result : result . result ?. value !== undefined ? result . result . value : result . result ,
1279+ result : extractedResult ,
12601280 exceptionDetails : result . exceptionDetails
12611281 } ;
12621282 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments