[GH-ISSUE #1341] scripting always fails with reference to __mapSwiftArrayToJSObject unless async #1334

Open
opened 2026-03-03 19:50:36 +03:00 by kerem · 6 comments
Owner

Originally created by @ddissett on GitHub (Aug 31, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1341

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

Version 3.8.0 (30800)

macOS Version? (Ex. mac 10.14)

10.14.6 (18G9323)

Steps to reproduce

  1. Fresh install
  2. create sync scripting item targeting any https: page that includes onResponse() and/or onRequest() function(s):

function onRequest(context, url, request) {
console.log(request);
return request;
}

function onResponse(context, url, request, response) {
console.log(response);
return response;
}

Expected behavior

request and/or response on* function is called and request and/or response object is logged to the console what that page is loaded thru the proxy

Screenshots (optional)

CleanShot 2022-08-31 at 01 24 46

Instead the function(s) fail with the following errors:


01:22:15.071: [onRequest] with Request ID=165
Run onRequest() func as normal (sync) mode
Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject

01:22:15.227: [onResponse] with Request ID=165
Run onResponse() func as normal (sync) mode
Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject

This happens for every script I've tried to create both in the public and Setapp versions of Proxyman.

If I change the functions to async, I do not get the error message, but the onRequest and/or onResponse functions don't appear to run.

Originally created by @ddissett on GitHub (Aug 31, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1341 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) Version 3.8.0 (30800) ### macOS Version? (Ex. mac 10.14) 10.14.6 (18G9323) ### Steps to reproduce 1) Fresh install 2) create sync scripting item targeting any https: page that includes onResponse() and/or onRequest() function(s): function onRequest(context, url, request) { console.log(request); return request; } function onResponse(context, url, request, response) { console.log(response); return response; } ### Expected behavior request and/or response on* function is called and request and/or response object is logged to the console what that page is loaded thru the proxy ### Screenshots (optional) ![CleanShot 2022-08-31 at 01 24 46](https://user-images.githubusercontent.com/80232560/187634008-dd438bf5-fa35-476b-ae12-62591abe6ce3.jpg) Instead the function(s) fail with the following errors: ---------------------------------- 01:22:15.071: [onRequest] with Request ID=165 Run onRequest() func as normal (sync) mode ❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject ---------------------------------- 01:22:15.227: [onResponse] with Request ID=165 Run onResponse() func as normal (sync) mode ❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject This happens for every script I've tried to create both in the public and Setapp versions of Proxyman. If I change the functions to async, I do not get the error message, but the onRequest and/or onResponse functions don't appear to run.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 31, 2022):

Thanks for the report @ddissett, but I could not reproduce it with a POST Request (JSON Both).

Screen Shot 2022-08-31 at 15 38 51

If you don't mind, what kind of your request?

  • Have Query?
  • Body Type (JSON, form, Text, Raw Data, ...)
  • Content-Type of the Request/Response Header.

I'd like to investigate it 👍

<!-- gh-comment-id:1232643993 --> @NghiaTranUIT commented on GitHub (Aug 31, 2022): Thanks for the report @ddissett, but I could not reproduce it with a POST Request (JSON Both). <img width="1840" alt="Screen Shot 2022-08-31 at 15 38 51" src="https://user-images.githubusercontent.com/5878421/187635588-2272064b-dc73-491a-bb19-8ef3456efd89.png"> If you don't mind, what kind of your request? - Have Query? - Body Type (JSON, form, Text, Raw Data, ...) - Content-Type of the Request/Response Header. I'd like to investigate it 👍
Author
Owner

@ddissett commented on GitHub (Sep 19, 2022):

Hello, sorry for the delayed response. Here is some more information. I am able to reproduce the problem with just about any request. Therefore, here is a very simple example with a request against the web server running on my mac:

GET /~ddissett/ HTTP/1.1
Host: continuity
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6,2 Safari/605.1.15
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

Here is the response headers:

HTTP/1.1 200 OK
Date: Mon, 19 Sep 2022 17:04:47 GMT
Server: Apache/2.4.34 (Unix) LibreSSL/2.5.5 mod_perl/2.0.9 Perl/v5.18.4
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html;charset=UTF-8
Expires: 0
Cache-Control: no-cache

I've attached a screenshot of the script and console output. Note: the first two items in the console (10:04:36) are from the displayed script but with async function rather than function on lines 1 and 6. I don't know if this is related, but note that the request and response objects logged in lines 2 and 7 are not in the log. In fact, I can't get an async function to do anything it seems. The next two log items (10:04:47) show the problem at hand (no async in front of the function def).

image

<!-- gh-comment-id:1251325174 --> @ddissett commented on GitHub (Sep 19, 2022): Hello, sorry for the delayed response. Here is some more information. I am able to reproduce the problem with just about any request. Therefore, here is a very simple example with a request against the web server running on my mac: GET /~ddissett/ HTTP/1.1 Host: continuity Upgrade-Insecure-Requests: 1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6,2 Safari/605.1.15 Accept-Language: en-US,en;q=0.9 Accept-Encoding: gzip, deflate Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Here is the response headers: HTTP/1.1 200 OK Date: Mon, 19 Sep 2022 17:04:47 GMT Server: Apache/2.4.34 (Unix) LibreSSL/2.5.5 mod_perl/2.0.9 Perl/v5.18.4 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html;charset=UTF-8 Expires: 0 Cache-Control: no-cache I've attached a screenshot of the script and console output. Note: the first two items in the console (10:04:36) are from the displayed script but with `async function` rather than `function` on lines 1 and 6. I don't know if this is related, but note that the request and response objects logged in lines 2 and 7 are not in the log. In fact, I can't get an `async function` to do anything it seems. The next two log items (10:04:47) show the problem at hand (no `async` in front of the function def). ![image](https://user-images.githubusercontent.com/80232560/191080356-53c9b7a3-1696-439f-8b61-b653f3b9387e.png)
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 20, 2022):

It seems that you're using very old macOS version, which is Intel Mac OS X 10_15_6.

I could not reproduce it on macOS 12.6, so it's guessed fixed. Please try this build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_3.10.0_Fix_scripting.dmg

I explicitly evaluate the __mapSwiftArrayToJSObject function, so it's always available.

<!-- gh-comment-id:1251764369 --> @NghiaTranUIT commented on GitHub (Sep 20, 2022): It seems that you're using very old macOS version, which is Intel Mac OS X 10_15_6. I could not reproduce it on macOS 12.6, so it's guessed fixed. Please try this build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_3.10.0_Fix_scripting.dmg I explicitly evaluate the `__mapSwiftArrayToJSObject` function, so it's always available.
Author
Owner

@ddissett commented on GitHub (Sep 21, 2022):

Yes. I am using an upgraded Mac Pro 4,1 and Mojave is the last version of MacOS supported on that hardware. I plan on inkling OpenCore so I can run unsupported versions, but that is a big project from what I understand.

will try in the version you posted. Thank you!

<!-- gh-comment-id:1253218728 --> @ddissett commented on GitHub (Sep 21, 2022): Yes. I am using an upgraded Mac Pro 4,1 and Mojave is the last version of MacOS supported on that hardware. I plan on inkling OpenCore so I can run unsupported versions, but that is a big project from what I understand. will try in the version you posted. Thank you!
Author
Owner

@ddissett commented on GitHub (Sep 21, 2022):

It still doesn't work with the version you posted and there's an additional error message now:

with async function:

----------------------------------
22:42:13.717: [onRequest] with Request ID=127
Run onRequest() func with async/await mode
❌Error: SyntaxError: Unexpected token '.' 
----------------------------------
22:42:13.747: [onResponse] with Request ID=127
Run onResponse() func with async/await mode

with no async:

----------------------------------
22:44:57.129: [onRequest] with Request ID=144
Run onRequest() func as normal (sync) mode
❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject 
❌Error: SyntaxError: Unexpected token '.' 
----------------------------------
22:44:57.158: [onResponse] with Request ID=144
Run onResponse() func as normal (sync) mode
❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject 
<!-- gh-comment-id:1253233453 --> @ddissett commented on GitHub (Sep 21, 2022): It still doesn't work with the version you posted and there's an additional error message now: with `async function`: ---------------------------------- 22:42:13.717: [onRequest] with Request ID=127 Run onRequest() func with async/await mode ❌Error: SyntaxError: Unexpected token '.' ---------------------------------- 22:42:13.747: [onResponse] with Request ID=127 Run onResponse() func with async/await mode with no `async`: ---------------------------------- 22:44:57.129: [onRequest] with Request ID=144 Run onRequest() func as normal (sync) mode ❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject ❌Error: SyntaxError: Unexpected token '.' ---------------------------------- 22:44:57.158: [onResponse] with Request ID=144 Run onResponse() func as normal (sync) mode ❌Error: ReferenceError: Can't find variable: __mapSwiftArrayToJSObject
Author
Owner

@ddissett commented on GitHub (Apr 4, 2025):

I suggest this be closed not planned stale. Its no longer relevant to me and probably no one else. Thanks.

<!-- gh-comment-id:2777873862 --> @ddissett commented on GitHub (Apr 4, 2025): I suggest this be closed not planned stale. Its no longer relevant to me and probably no one else. Thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1334
No description provided.