Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-PodeWebForm ScriptBlock Rerunning Itself Every 30 Seconds After Submit Until Response Timeout Reached #529

Closed
jbaechtelMT opened this issue Jan 19, 2024 · 2 comments · Fixed by #534
Assignees
Labels
bug 🐛 Something isn't working
Milestone

Comments

@jbaechtelMT
Copy link

jbaechtelMT commented Jan 19, 2024

Describe the Bug

I originally (yesterday) posted this on the Pode site as a question about the maximum value for Response Timeout. Seems that if I set the Timeout value to 600 (seconds - 5 Mins.), the Response timed out at 3 mins. and 30 seconds (See Pode Issue Related: ([https://github.com/Badgerati/Pode/issues/1235]))

Although the Response Timeout maximum value question still remains, I did some additional digging and found that it looks like New-PodeWebForm ScriptBlock also has a bug.

Here's the issue: If the ScriptBlock code runs for greater than 30 seconds, something is executing the ScriptBlock again and again every 30 seconds until the Response Timeout of 3 mins. and 30 seconds is reached.

Steps To Reproduce

  1. Create a page with a simple Web Form on it
  2. In the ScriptBlock, add this code: Write-PodeHost "Calling ScriptBlock"; Start-Sleep -Seconds 45
  3. Set your Pode Response Timeout value to 600 (seconds).
  4. Start Pode in a Powershell session (Run as Administrator)
  5. In a browser, navigate to your page/form and click on the Submit button
  6. What you will see in your browser is a spinner on the Submit Button for 3 mins. and 30 seconds.
  7. What you will see in your PowerShell session window is the phrase "Calling ScriptBlock", every 30 seconds until the Pode Response Time occurs at 3 mins. and 30 seconds. Then the Submit spinner in the browser page/form will stop spinning.

Expected Behavior

  1. Pode Response Timeout should allow for setting the value to something larger than 210 seconds (3 mins. and 30 seconds), and honor that setting.
  2. Pode.Web New-PodeWebForm ScriptBlock should not be re-executed every 30 seconds. It should run once unless the Submit button is clicked again.

Screenshots

image

image

Platform

  • OS: Windows
  • Browser: Chrome
  • Versions:
    • Pode: v2.9.0
    • Pode.Web: v0.8.2 - Upgraded to v0.8.3 - Issue persists
    • PowerShell: PS v5.1 Build: 19041 Revision: 3570

Additional Context

What I believe to be a Pode.Web New-PodeWebForm ScriptBlock bug, is what made me start looking at increasing the Pode Response Timeout value.

Now that I think of it: This behavior has been happening for a very long time. For long running pages like getting all AD users or Groups and displaying them in a table, this is what moved me to using Timer jobs to get that information and populating it into SQL tables or Pode variables. Then the page/table display code would fetch the needed information from either the SQL tables or the Pode variables.

@jbaechtelMT jbaechtelMT added the bug 🐛 Something isn't working label Jan 19, 2024
@Badgerati
Copy link
Owner

Hi @jbaechtelMT,

It's actually AJAX that's doing the 30secs auto-recall, and triggering the Forms scriptblock repeatedly. The last time I looked, I couldn't see an option to stop AJAX from doing this, but maybe there is one now! I'll have a gander at the AJAX docs, see if I can spot anything; it might even just be a case of altering an AJAX timeout potentially.

@Badgerati Badgerati self-assigned this Feb 4, 2024
@Badgerati Badgerati added this to the 1.0.0 milestone Feb 4, 2024
@Badgerati
Copy link
Owner

Hi @jbaechtelMT,

The above commit should now fix the Form timing out, so long as it's still less than the configured Request Timeout in your server.psd1.

For the Form/Ajax calling the endpoint again and again, sadly there isn't anything I can do - it's actually by design within most browsers in accordance with the HTTP/1.1 spec:

So long as the Form's duration is less than Pode's Request Timeout, the browser won't attempt to retry the endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants