[GH-ISSUE #1190] Scripting - only first script is applied if there are multiple scripts enabled for the same endpoint #1186

Closed
opened 2026-03-03 19:49:03 +03:00 by kerem · 31 comments
Owner

Originally created by @adrianwoda-viacom on GitHub (Mar 29, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1190

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

3.3.0

macOS Version? (Ex. mac 10.14)

12.3

Steps to reproduce

So currently if user has more than one scripts for the same endpoint, only the first one (on the top) is actually applied. Others are skipped.

How to reproduce:

  • open scripting tool
  • create two scripts for the same endpoint
  • add to onResponse() method:
function onResponse(context, url, request, response) {
  console.log("second");
  return response;
}

on first script - console.log("first")
on second script - console.log("second")

  • save them and enable
  • open console
  • fire the call

actual:
on console, you will only see the "first" message but no "second", which means that only the first script was applied

expected:
I would love to be able to launch multiple scripts for the same request but in the order preserved as on the script list.

Originally created by @adrianwoda-viacom on GitHub (Mar 29, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1190 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) 3.3.0 ### macOS Version? (Ex. mac 10.14) 12.3 ### Steps to reproduce So currently if user has more than one scripts for the same endpoint, only the first one (on the top) is actually applied. Others are skipped. How to reproduce: - open scripting tool - create two scripts for the same endpoint - add to onResponse() method: ``` function onResponse(context, url, request, response) { console.log("second"); return response; } ``` on first script - console.log("first") on second script - console.log("second") - save them and enable - open console - fire the call actual: on console, you will only see the "first" message but no "second", which means that only the first script was applied expected: I would love to be able to launch multiple scripts for the same request but in the order preserved as on the script list.
kerem 2026-03-03 19:49:03 +03:00
Author
Owner

@NghiaTranUIT commented on GitHub (Mar 30, 2022):

Yes, it's our intention. We don't allow multiple scripts to be executed for 1 request/response.

Just wondering: Why do you need to execute multiple scripts? Why don't you write a single one, which contains all you need?

<!-- gh-comment-id:1082721014 --> @NghiaTranUIT commented on GitHub (Mar 30, 2022): Yes, it's our intention. We don't allow multiple scripts to be executed for 1 request/response. Just wondering: Why do you need to execute multiple scripts? Why don't you write a single one, which contains all you need?
Author
Owner

@adrianwoda-viacom commented on GitHub (Mar 30, 2022):

first of all, there is no information on the app that only the first script will be applied. This leads to a misunderstanding of how the feature should work. My coworkers who use your tool also made that mistake, unfortunately :)

I want to have the ability to have multiple scripts assigned to one endpoint for a few reasons:

  1. I don't want to remember and constantly change the order of the scripts if I have more than one
  2. sometimes I just want to have multiple scripts to change different parts of the same endpoint's response. eg. one script may change one parameter of response and others change another. I know I can do this on the one function, but to disable and enable features I will need to change (comment/uncomment or change flags) the code. If multiple scripting would be possible, only enabling/disabling rule by mouse click will be needed to accomplish the same results. This would drastically improve the UX 👍🏼
  3. because you can use wildcards/regexp in the URL pattern, without this feature you actually may unintended have two scripts for the same endpoint and you will not be aware of that until you realise that the second script is not working
<!-- gh-comment-id:1082842141 --> @adrianwoda-viacom commented on GitHub (Mar 30, 2022): first of all, there is no information on the app that only the first script will be applied. This leads to a misunderstanding of how the feature should work. My coworkers who use your tool also made that mistake, unfortunately :) I want to have the ability to have multiple scripts assigned to one endpoint for a few reasons: 1. I don't want to remember and constantly change the order of the scripts if I have more than one 2. sometimes I just want to have multiple scripts to change different parts of the same endpoint's response. eg. one script may change one parameter of response and others change another. I know I can do this on the one function, but to disable and enable features I will need to change (comment/uncomment or change flags) the code. If multiple scripting would be possible, only enabling/disabling rule by mouse click will be needed to accomplish the same results. This would drastically improve the UX 👍🏼 3. because you can use wildcards/regexp in the URL pattern, without this feature you actually may unintended have two scripts for the same endpoint and you will not be aware of that until you realise that the second script is not working
Author
Owner

@NghiaTranUIT commented on GitHub (Mar 30, 2022):

Thanks for your input @adrianwoda-viacom 👍

  1. I don't want to remember and constantly change the order of the scripts if I have more than one

Currently, Proxyman will try to find the matched script by Top-Down order. If the Regex/wildcard is matched, this script is executed. Other scripts are ignored.

sometimes I just want to have multiple scripts to change different parts of the same endpoint's response. eg. one script may change one parameter of response and others change another. I know I can do this on the one function, but to disable and enable features I will need to change (comment/uncomment or change flags) the code. If multiple scripting would be possible, only enabling/disabling rule by mouse click will be needed to accomplish the same results. This would drastically improve the UX 👍🏼

Thanks for your insight. We intentionally design this way, so the user can be aware of which script should be executed by explicitly enabling/disabling the rule.

If we allow multiple scripts can be executed, it's hard to trace down which one should be executed first, or later.

because you can use wildcards/regexp in the URL pattern, without this feature you actually may unintended have two scripts for the same endpoint and you will not be aware of that until you realize that the second script is not working

Yes, there are multiple Regex/Wildcard rules that can match the given request's URL, however, the first one (top-down) will be executed.


Anyway, I will escalate to the dev and see if might support multiple scripts.

<!-- gh-comment-id:1082889503 --> @NghiaTranUIT commented on GitHub (Mar 30, 2022): Thanks for your input @adrianwoda-viacom 👍 > 1. I don't want to remember and constantly change the order of the scripts if I have more than one Currently, Proxyman will try to find the matched script by Top-Down order. If the Regex/wildcard is matched, this script is executed. Other scripts are ignored. > sometimes I just want to have multiple scripts to change different parts of the same endpoint's response. eg. one script may change one parameter of response and others change another. I know I can do this on the one function, but to disable and enable features I will need to change (comment/uncomment or change flags) the code. If multiple scripting would be possible, only enabling/disabling rule by mouse click will be needed to accomplish the same results. This would drastically improve the UX 👍🏼 Thanks for your insight. We intentionally design this way, so the user can be aware of which script should be executed by explicitly enabling/disabling the rule. If we allow multiple scripts can be executed, it's hard to trace down which one should be executed first, or later. > because you can use wildcards/regexp in the URL pattern, without this feature you actually may unintended have two scripts for the same endpoint and you will not be aware of that until you realize that the second script is not working Yes, there are multiple Regex/Wildcard rules that can match the given request's URL, however, the first one (top-down) will be executed. ----------------- Anyway, I will escalate to the dev and see if might support multiple scripts.
Author
Owner

@adrianwoda-viacom commented on GitHub (Mar 30, 2022):

thanks, looking forward to hearing from you

<!-- gh-comment-id:1082910242 --> @adrianwoda-viacom commented on GitHub (Mar 30, 2022): thanks, looking forward to hearing from you
Author
Owner

@aruudboy commented on GitHub (Nov 10, 2022):

Any updates on this @NghiaTranUIT? I'm running Proxyman 3.13.0 (31300) on MacOS Ventura 13.0, and I experience the same as originally reported here.

I can heavily relate to point 2 raised by @adrianwoda-viacom - I would love to be able to chose at will which parts of the response from one particular endpoint that I would like changed with different scripts without the need of changing the code of a single script. This is something I often did with Charles during regression tests, but as a business we've started our move over to Proxyman. :)

<!-- gh-comment-id:1309884592 --> @aruudboy commented on GitHub (Nov 10, 2022): Any updates on this @NghiaTranUIT? I'm running Proxyman 3.13.0 (31300) on MacOS Ventura 13.0, and I experience the same as originally reported here. I can heavily relate to point 2 raised by @adrianwoda-viacom - I would love to be able to chose at will which parts of the response from one particular endpoint that I would like changed with different scripts without the need of changing the code of a single script. This is something I often did with Charles during regression tests, but as a business we've started our move over to Proxyman. :)
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 10, 2022):

Thanks for your input @aruudboy.

I guess I can add an option to allow executing multiple scripts, but keep the current behavior (1 script at once) as a default setting.

and this change is exclusive to the scripting.

<!-- gh-comment-id:1309963930 --> @NghiaTranUIT commented on GitHub (Nov 10, 2022): Thanks for your input @aruudboy. I guess I can add an option to allow executing multiple scripts, but keep the current behavior (1 script at once) as a default setting. and this change is exclusive to the scripting.
Author
Owner

@aruudboy commented on GitHub (Nov 10, 2022):

Thank you very much @NghiaTranUIT, I'm looking forward to try it out!

<!-- gh-comment-id:1310278533 --> @aruudboy commented on GitHub (Nov 10, 2022): Thank you very much @NghiaTranUIT, I'm looking forward to try it out!
Author
Owner

@aruudboy commented on GitHub (Jan 3, 2023):

Just following up on this @NghiaTranUIT.

I have updated to 3.15.0, and didn't see this as part of the release notes - and the behaviour is also the same as before. Do you know if this option will be available in any later versions of Proxyman?

<!-- gh-comment-id:1369492286 --> @aruudboy commented on GitHub (Jan 3, 2023): Just following up on this @NghiaTranUIT. I have updated to 3.15.0, and didn't see this as part of the release notes - and the behaviour is also the same as before. Do you know if this option will be available in any later versions of Proxyman?
Author
Owner

@NghiaTranUIT commented on GitHub (Jan 3, 2023):

Sorry @aruudboy I did it, but implementing both: Multiple scripts (new feature) and a single script (current feature) doesn't work well and doesn't satisfy my standard. I'd like to postpone to suppose this feature until there are more requests on this 👍

<!-- gh-comment-id:1369588467 --> @NghiaTranUIT commented on GitHub (Jan 3, 2023): Sorry @aruudboy I did it, but implementing both: Multiple scripts (new feature) and a single script (current feature) doesn't work well and doesn't satisfy my standard. I'd like to postpone to suppose this feature until there are more requests on this 👍
Author
Owner

@aruudboy commented on GitHub (Jan 5, 2023):

I fully support your decision - thank you for replying, and for the work you're doing on Proxyman!

<!-- gh-comment-id:1371849602 --> @aruudboy commented on GitHub (Jan 5, 2023): I fully support your decision - thank you for replying, and for the work you're doing on Proxyman!
Author
Owner

@lesyuk commented on GitHub (Mar 5, 2023):

Unfortunately, in my particular case, I abandoned the use of the Proxyman in favor of Charles due to the lack of this feature.

It's very important for me to have a general rule for the entire domain using a wildcard, and separate rules for child methods. Now this is impossible.

<!-- gh-comment-id:1455118200 --> @lesyuk commented on GitHub (Mar 5, 2023): Unfortunately, in my particular case, I abandoned the use of the Proxyman in favor of Charles due to the lack of this feature. It's very important for me to have a general rule for the entire domain using a wildcard, and separate rules for child methods. Now this is impossible.
Author
Owner

@barbrzez commented on GitHub (Jun 20, 2023):

@NghiaTranUIT
The company I work for is currently in final stages of Macbook rollout planning.
I have been evaluating different web-debugging solutions. So far, proxyman has been my favourite, but the lack of this feature may be a deal-breaker for us.

We need to be able to perform different actions for the same domain, and be able to quickly toggle some of these actions on/off.

This can be resolved with different scripts and the switches in the script list, but unfortunately only one script can ever be executed.

The alternative that I can see is to use one script per domain, and to use add-ons to handle different behaviour, but even then we need the ability to quickly toggle behaviour on/off. Fiddler Classic allows plugins to contribute additional elements to the app's menu bar, items that modify the global state which the scripts can then read and apply the logic as required.

Please let me know your thoughts, or perhaps there is an alternative solution that I've not considered?

<!-- gh-comment-id:1598910105 --> @barbrzez commented on GitHub (Jun 20, 2023): @NghiaTranUIT The company I work for is currently in final stages of Macbook rollout planning. I have been evaluating different web-debugging solutions. So far, proxyman has been my favourite, but the lack of this feature may be a deal-breaker for us. We need to be able to perform different actions for the same domain, and be able to quickly toggle some of these actions on/off. This can be resolved with different scripts and the switches in the script list, but unfortunately only one script can ever be executed. The alternative that I can see is to use one script per domain, and to use add-ons to handle different behaviour, but even then we need the ability to quickly toggle behaviour on/off. Fiddler Classic allows plugins to contribute additional elements to the app's menu bar, items that modify the global state which the scripts can then read and apply the logic as required. Please let me know your thoughts, or perhaps there is an alternative solution that I've not considered?
Author
Owner

@NghiaTranUIT commented on GitHub (Jun 20, 2023):

Thanks for your input @barbrzez. I will move this ticket to the next release. Will send a Beta build here for testing 👍

Just to clarify that this "Multiple Scripts" is disabled by default, and it can be enabled in the Advanced Options.

Here is what it looks like (I suppose):

  • Able to execute multiple scripts if it's enabled.
  • Execute each script by order (Top to down) if the URL is matched.
  • If one script is failed (e.g. syntax error), it will skip and move to the next script.
  • Has a Note somewhere (maybe in the Summary Tab), to explain what scripts are executed successfully or failed => Easier to debug.
<!-- gh-comment-id:1598936940 --> @NghiaTranUIT commented on GitHub (Jun 20, 2023): Thanks for your input @barbrzez. I will move this ticket to the next release. Will send a Beta build here for testing 👍 Just to clarify that this "Multiple Scripts" is disabled by default, and it can be enabled in the Advanced Options. Here is what it looks like (I suppose): - Able to execute multiple scripts if it's enabled. - Execute each script by order (Top to down) if the URL is matched. - If one script is failed (e.g. syntax error), it will skip and move to the next script. - Has a Note somewhere (maybe in the Summary Tab), to explain what scripts are executed successfully or failed => Easier to debug.
Author
Owner

@NghiaTranUIT commented on GitHub (Jun 23, 2023):

Hey @barbrzez @lesyuk, @aruudboy @adrianwoda-viacom if you guys don't mind, let's try this Beta build: https://download.proxyman.io/beta/Proxyman_4.8.1_Support_Multiple_Scripts.dmg

  • Able to execute multiple scripts if it's enabled. Enable it in Setting -> Tool -> Scripting Section
  • Execute each script by order (Top to down) if the URL is matched.
  • Mock API is disabled if this feature is enabled
  • You can find the Script in the Summary Tab -> Debugging Tool section

CleanShot 2023-06-23 at 15 28 32@2x


Let me know if it works. If there are bugs, I'm all hears to fix it 👍

<!-- gh-comment-id:1603929772 --> @NghiaTranUIT commented on GitHub (Jun 23, 2023): Hey @barbrzez @lesyuk, @aruudboy @adrianwoda-viacom if you guys don't mind, let's try this Beta build: https://download.proxyman.io/beta/Proxyman_4.8.1_Support_Multiple_Scripts.dmg - Able to execute multiple scripts if it's enabled. Enable it in Setting -> Tool -> Scripting Section - Execute each script by order (Top to down) if the URL is matched. - Mock API is disabled if this feature is enabled - You can find the Script in the Summary Tab -> Debugging Tool section ![CleanShot 2023-06-23 at 15 28 32@2x](https://github.com/ProxymanApp/Proxyman/assets/5878421/b6f58212-165f-4f66-852e-08fe20b9a213) -------- Let me know if it works. If there are bugs, I'm all hears to fix it 👍
Author
Owner

@barbrzez commented on GitHub (Jun 23, 2023):

@NghiaTranUIT many thanks for addressing this so quickly.

Two behaviours that I've noticed (and please bear in mind I don't know proxyman that well yet) are:

  • When Tools -> Debugging Tools -> Append Proxyman Headers to matched flows is selected, only the last script executed is listed in the response headers. This is a minor one, but it would still be good to get visibility of what's happening.
  • If both Map Remote and some Scripts match the same request, only the scripts get executed, with no information that the Remote tool has not worked.
<!-- gh-comment-id:1604063784 --> @barbrzez commented on GitHub (Jun 23, 2023): @NghiaTranUIT many thanks for addressing this so quickly. Two behaviours that I've noticed (and please bear in mind I don't know proxyman that well yet) are: * When _Tools_ -> _Debugging Tools_ -> _Append Proxyman Headers to matched flows_ is selected, only the last script executed is listed in the response headers. This is a minor one, but it would still be good to get visibility of what's happening. * If both _Map Remote_ and some _Scripts_ match the same request, only the scripts get executed, with no information that the Remote tool has not worked.
Author
Owner

@NghiaTranUIT commented on GitHub (Jun 23, 2023):

When Tools -> Debugging Tools -> Append Proxyman Headers to matched flows are selected, only the last script executed is listed in the response headers. This is a minor one, but it would still be good to get visibility of what's happening.

Yes, it's a bug. I'm going to fix it now 👍

If both Map Remote and some Scripts match the same request, only the scripts get executed, with no information that the Remote tool has not worked.

It's our decision. Map Remote doesn't work with Scripting.

<!-- gh-comment-id:1604102098 --> @NghiaTranUIT commented on GitHub (Jun 23, 2023): > When Tools -> Debugging Tools -> Append Proxyman Headers to matched flows are selected, only the last script executed is listed in the response headers. This is a minor one, but it would still be good to get visibility of what's happening. Yes, it's a bug. I'm going to fix it now 👍 > If both Map Remote and some Scripts match the same request, only the scripts get executed, with no information that the Remote tool has not worked. It's our decision. Map Remote doesn't work with Scripting.
Author
Owner

@NghiaTranUIT commented on GitHub (Jun 23, 2023):

@barbrzez you can write a small JS code to change the host/path/scheme/query ... similar to Map Remote does

<!-- gh-comment-id:1604104137 --> @NghiaTranUIT commented on GitHub (Jun 23, 2023): @barbrzez you can write a small JS code to change the [host/path/scheme/query](https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path) ... similar to Map Remote does
Author
Owner

@barbrzez commented on GitHub (Jun 26, 2023):

@barbrzez you can write a small JS code to change the host/path/scheme/query ... similar to Map Remote does

@NghiaTranUIT yep thanks, we will use that going forwards.

<!-- gh-comment-id:1607823609 --> @barbrzez commented on GitHub (Jun 26, 2023): > @barbrzez you can write a small JS code to change the [host/path/scheme/query](https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path) ... similar to Map Remote does @NghiaTranUIT yep thanks, we will use that going forwards.
Author
Owner

@NghiaTranUIT commented on GitHub (Jul 14, 2023):

Update #3

<!-- gh-comment-id:1635160523 --> @NghiaTranUIT commented on GitHub (Jul 14, 2023): ### Update #3 - Beta: https://download.proxyman.io/beta/Proxyman_4.8.2_Multiple_scripts_v3.dmg - With the latest features from Proxyman 4.8.2
Author
Owner

@adrianwoda-viacom commented on GitHub (Sep 6, 2023):

@NghiaTranUIT when do you guys expect to add this to official release?

<!-- gh-comment-id:1708196819 --> @adrianwoda-viacom commented on GitHub (Sep 6, 2023): @NghiaTranUIT when do you guys expect to add this to official release?
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 6, 2023):

Soon if you don't mind to test this Beta build on your end @adrianwoda-viacom, to check if it works as you expect 🤔

<!-- gh-comment-id:1708266616 --> @NghiaTranUIT commented on GitHub (Sep 6, 2023): Soon if you don't mind to test this Beta build on your end @adrianwoda-viacom, to check if it works as you expect 🤔
Author
Owner

@adrianwoda-viacom commented on GitHub (Sep 7, 2023):

@NghiaTranUIT I've tested it and for me it works great - exactly as I want. It suits my and few of my colleagues needs! Can't wait for the release!

<!-- gh-comment-id:1709701039 --> @adrianwoda-viacom commented on GitHub (Sep 7, 2023): @NghiaTranUIT I've tested it and for me it works great - exactly as I want. It suits my and few of my colleagues needs! Can't wait for the release!
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 7, 2023):

Thanks @adrianwoda-viacom I will send a new Beta update today for you. Please use this Beta build awhile and report the bug if you don't mind 👍

If everything is good, I can release this version in the new update 👍

<!-- gh-comment-id:1709794970 --> @NghiaTranUIT commented on GitHub (Sep 7, 2023): Thanks @adrianwoda-viacom I will send a new Beta update today for you. Please use this Beta build awhile and report the bug if you don't mind 👍 If everything is good, I can release this version in the new update 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 7, 2023):

Beta v4:

@adrianwoda-viacom please use this build for 1-2 weeks. If there is no major issue, I will include it in the next release 👍

<!-- gh-comment-id:1710082764 --> @NghiaTranUIT commented on GitHub (Sep 7, 2023): ### Beta v4: - https://download.proxyman.io/beta/Proxyman_4.10.0_Multiscripts_v4.dmg - Update with the latest Proxyman macOS 4.10.0 @adrianwoda-viacom please use this build for 1-2 weeks. If there is no major issue, I will include it in the next release 👍
Author
Owner

@adrianwoda-viacom commented on GitHub (Sep 7, 2023):

@NghiaTranUIT thanks! Will do! 👍🏼

<!-- gh-comment-id:1710185398 --> @adrianwoda-viacom commented on GitHub (Sep 7, 2023): @NghiaTranUIT thanks! Will do! 👍🏼
Author
Owner

@adrianwoda-viacom commented on GitHub (Sep 13, 2023):

@NghiaTranUIT after almost a week, I'm pretty satisfied how it works :)

<!-- gh-comment-id:1717159810 --> @adrianwoda-viacom commented on GitHub (Sep 13, 2023): @NghiaTranUIT after almost a week, I'm pretty satisfied how it works :)
Author
Owner

@adrianwoda-viacom commented on GitHub (Sep 28, 2023):

@NghiaTranUIT when you plan to release? :) Green light from me

<!-- gh-comment-id:1738643358 --> @adrianwoda-viacom commented on GitHub (Sep 28, 2023): @NghiaTranUIT when you plan to release? :) Green light from me
Author
Owner

@barbrzez commented on GitHub (Sep 28, 2023):

@NghiaTranUIT another vote from myself :)

<!-- gh-comment-id:1738770044 --> @barbrzez commented on GitHub (Sep 28, 2023): @NghiaTranUIT another vote from myself :)
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 28, 2023):

Awesome. I will include it in the next release. ETA: This weekend 👍

<!-- gh-comment-id:1738773957 --> @NghiaTranUIT commented on GitHub (Sep 28, 2023): Awesome. I will include it in the next release. ETA: This weekend 👍
Author
Owner

@aruudboy commented on GitHub (Oct 4, 2023):

Wow, I didn't see the notification when you tagged me @NghiaTranUIT - I just saw this feature is the latest release notes, and got to test it out now. IT WORKS PERFECTLY! 🎉 Thanks a lot!

<!-- gh-comment-id:1746477165 --> @aruudboy commented on GitHub (Oct 4, 2023): Wow, I didn't see the notification when you tagged me @NghiaTranUIT - I just saw this feature is the latest release notes, and got to test it out now. IT WORKS PERFECTLY! 🎉 Thanks a lot!
Author
Owner

@adrianwoda-viacom commented on GitHub (Oct 9, 2023):

because issue is fixed, I'm closing the ticket. Thank you all.

<!-- gh-comment-id:1752524676 --> @adrianwoda-viacom commented on GitHub (Oct 9, 2023): because issue is fixed, I'm closing the ticket. Thank you all.
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#1186
No description provided.