[GH-ISSUE #1275] scripting timeout #1268

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

Originally created by @webuniverseio on GitHub (Jun 28, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1275

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

3.6.0

macOS Version? (Ex. mac 10.14)

12.3.1

Steps to reproduce

Try scripting with this code

await new Promise(resolve => setTimeout(resolve, 10000))

Expected behavior

Expect hanging request for 10s before other scripting logic will execute. Instead getting scripting error (I know JS engine doesn't support Promise, but then at least some js cases are not possible to implement)

Screenshots (optional)

Originally created by @webuniverseio on GitHub (Jun 28, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1275 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) 3.6.0 ### macOS Version? (Ex. mac 10.14) 12.3.1 ### Steps to reproduce Try scripting with this code ``` await new Promise(resolve => setTimeout(resolve, 10000)) ``` ### Expected behavior Expect hanging request for 10s before other scripting logic will execute. Instead getting scripting error (I know JS engine doesn't support Promise, but then at least some js cases are not possible to implement) ### Screenshots (optional)
kerem closed this issue 2026-03-03 19:49:54 +03:00
Author
Owner

@webuniverseio commented on GitHub (Jun 28, 2022):

As a hack workaround I'm thinking of making a request to api which supports timeouts via parameters. Very hacky :D. It would be good to have a built in method like sleep(ms)

await $http.get('http://httpbin.org/delay/10')
<!-- gh-comment-id:1169324984 --> @webuniverseio commented on GitHub (Jun 28, 2022): As a hack workaround I'm thinking of making a request to api which supports timeouts via parameters. Very hacky :D. It would be good to have a built in method like sleep(ms) ``` await $http.get('http://httpbin.org/delay/10') ```
Author
Owner

@NghiaTranUIT commented on GitHub (Jun 29, 2022):

You get the error because setTimeout isn't implemented in the JavascriptCore. Meanwhile, it supports Promise.

For the $http func, the timeout at 10 seconds. Thus, it will work with await $http.get('http://httpbin.org/delay/10'), but you get timeout with await $http.get('http://httpbin.org/delay/15')

If you'd like to delay the request/response, you can simply use the sleep() function

async function onResponse(context, url, request, response) {
  console.log("Start sleep");
  
  // Sleep 30 seconds
  sleep(30000);
  
  // Done
  return response;
}

Ref: https://docs.proxyman.io/scripting/snippet-code#response-delay-with-sleep-function


If it's not what you're looking for, please let me know 😄


I guess I should implement the setTimeout function soon 👍

<!-- gh-comment-id:1169527253 --> @NghiaTranUIT commented on GitHub (Jun 29, 2022): You get the error because `setTimeout` isn't implemented in the JavascriptCore. Meanwhile, it supports Promise. For the `$http` func, the timeout at 10 seconds. Thus, it will work with `await $http.get('http://httpbin.org/delay/10')`, but you get timeout with `await $http.get('http://httpbin.org/delay/15')` If you'd like to delay the request/response, you can simply use the `sleep()` function ```js async function onResponse(context, url, request, response) { console.log("Start sleep"); // Sleep 30 seconds sleep(30000); // Done return response; } ``` Ref: https://docs.proxyman.io/scripting/snippet-code#response-delay-with-sleep-function -------------- If it's not what you're looking for, please let me know 😄 ---------- I guess I should implement the `setTimeout` function soon 👍
Author
Owner

@webuniverseio commented on GitHub (Jun 29, 2022):

Thanks, my bad, I need to read the manual 😅

<!-- gh-comment-id:1170244803 --> @webuniverseio commented on GitHub (Jun 29, 2022): Thanks, my bad, I need to read the manual 😅
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#1268
No description provided.