Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
359 stars 170 forks source link

Allow timeout to be specified for Get-ServiceNowRecord #246

Closed car1bo closed 10 months ago

car1bo commented 1 year ago

Summary of the new feature/enhancement

When running Get-ServiceNowRecord against busy instances, it appears that sometimes the server does not respond, and the request hangs indefinitely. The documentation for Invoke-WebRequest states that the default value for TimeOutSec is zero which represents an indefinite timeout.

Proposed technical implementation details

Add an optional parameter to Get-ServiceNowRecord for TimeOutSec which is then passed through Invoke-ServiceNowRestMethod to the Invoke-WebRequest function.

gdbarron commented 1 year ago

Hi @car1bo, thanks for the idea and PR! Since this is an instance level issue, would we be better served by including this in session creation, New-ServiceNowSession? That way the timeout value would be used for every function. Thoughts?

gdbarron commented 1 year ago

@car1bo following up....

gdbarron commented 1 year ago

@car1bo one last try

gregharms commented 10 months ago

I'm not the issue submitter, but as a consumer of a busy ServiceNow instance myself, I'd find that allowing a timeout value to be set would help avoid scripts hanging indefinitely. I would agree that setting the preferred timeout via New-ServiceNowSession would be best so that all functions interacting with the instance would share the same timeout.

gdbarron commented 10 months ago

Thanks @gregharms, I appreciate the feedback. I've added this functionality.