Console
Console copied to clipboard
Stack empty error when using Sitecore PowerShell Extensions dialog box
Expected Behavior
Please describe the expected behavior.
Sitecore PowerShell Extensions dialog box shouldn't throws any error if we perform any action parallel
Actual Behavior
Please describe the actual behavior. Sitecore PowerShell Extensions dialog box throws a stack empty error when publishing is performed in parallel
Steps to Reproduce the Problem
1.Open Sitecore PowerShell Extensions dialog box (e.g. “Create a new SXA site”) 2. Parallel open site in private window and publish an item 3. Come back to normal window click any button on the Sitecore PowerShell Extensions dialog box 4. You will see a stack empty error
Raised sitecore ticket, bug reference number: 438156
Error: [InvalidOperationException: Stack empty.] System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +60 System.Collections.Generic.Stack`1.Pop() +76 Spe.Commands.Interactive.Messages.ShowMultiValuePromptMessage.ProcessResult(Boolean hasResult, String sig) +120 Spe.Commands.Interactive.Messages.BasePipelineMessageWithResult.Pipeline(ClientPipelineArgs args) +451
Please include the version number of SPE and Sitecore. Sitecore 9.3
-
[ YES] Tested issue with clean install of Sitecore and the latest available version of SPE.
-
[NO ] Asked questions on the Sitecore Slack Chat channel.
-
[ YES] Reviewed questions and answers on the Sitecore Stack Exchange.
Can you please provide some screenshots or animated gif showing how you reproduce the issue?
Can you please provide some screenshots or animated gif showing how you reproduce the issue?
Hope this helps
https://www.screencast.com/t/lwQAzEoDFtY
I raised with sitecore support teams. They suggested me to connect with you
Interesting.
Does it happen if the second window is logged in as a different user following the same steps?
What about if you close the SPE window before hitting ok on the publish dialogue to close?
Interesting.
Does it happen if the second window is logged in as a different user following the same steps? yes What about if you close the SPE window before hitting ok on the publish dialogue to close? -Only on clicking ok in publish dialogue, we see this error
Hi Michaellwest,
Could you please provide a workaround/fix for this issue.
We are using Sitecore PowerShell Extensions dialog box to create a Article page. Where authors can create easily from sitecore desktop. At the same time there are chance from other authors uses the publishing options. This may breaks article creation flow.
Regards, Ashok
I'll certainly have a look at it. This is a community supported module. You are more than welcome to submit a PR if you have a possible solution in mind.
Hi Michaellwest,
I noticed this issue occurs when we are using only a Interactive Dialogs pop-up cmd "Read-Variable".
Do we any alternative PS dialog box command to read variables?
Regards, Ashok Karuturi
Hi Michaellwest,
Do we have any update on this issue ?
Regards, Ashok Karuturi
Hi Michaealweat,
Please find the sample code below. which we are using to create an article from a desktop view (https://www.screencast.com/t/v4v2urvaf3 )
This Article flow creating process helps our content editors to create a new article quick and easy with less sitecore knowledge. But when a parallel publishing happens from any user we are facing Stack Empty error. Kindly check the code and please provide if any workaround available for this.
Sample Code:
# Article Creation
#
Import-Function Validate-PowerShell
$sourceItem=$null
$itemName=$null
$dialogParams = @{
Title = "Create News Article Page"
Description = "Please select the below options"
OkButtonName = "Create"
CancelButtonName = "Close"
Icon = "Office/32x32/newspaper.png"
width = "600"
height = "600"
ShowHints = $true
Parameters = @(
@{
Name = "itemName"
Title = "Enter a name for the News Article:"
Mandatory = $true
}
@{
Name = "sourceItem"
Title = "Select a News Article Group:"
Editor = "droplist"
Source = "query:/sitecore/content/IPP/News/Home//*[@@templatename='News Home Page']"
Mandatory = $true
}
)
Validator = {
$selectedState = $variables.sourceItem.Value
if ($selectedState.TemplateID -ne "{8CEF8227-380A-4B96-8F1D-5F6FEDB6DC5A}") {
$variables.sourceItem.Error = "Please choose a valid News article Page."
}
$enteredText = $variables.itemName.Value
if($enteredText){
if ($enteredText -notmatch "^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$") {
$variables.itemName.Error = "$($enteredText) is not a valid name."
}
}
}
}
$dialogResult = Read-Variable @dialogParams
if($dialogResult -ne "ok"){
Exit
}
if($itemName){
try{
$item = New-Item -Path "master:$($sourceItem.Paths.FullPath)" -Name $itemName -ItemType "/sitecore/templates/Project/IPP/News Page"
#Import-Function Update-NewsItems
#Update-NewsItems $item
$editURL="/?sc_mode=edit&sc_itemid=$($item.ID)&sc_lang=en&sc_site=News"
Invoke-JavaScript -Script `
"window.open('$($editURL)', '_blank')"
}
catch
{
}
}
Error [InvalidOperationException: Stack empty.] System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +60 System.Collections.Generic.Stack`1.Pop() +76 Spe.Commands.Interactive.Messages.ShowMultiValuePromptMessage.ProcessResult(Boolean hasResult, String sig) +120 Spe.Commands.Interactive.Messages.BasePipelineMessageWithResult.Pipeline(ClientPipelineArgs args) +451
Regards, Ashok
@ashokkarutur, just to confirm is this tested on a clean install of Sitecore? Removing any custom code out of the equation would be very helpful.
@AlexKasaku Yes, this was reproducible by Sitecore support team as well "CS0195615"
Looks like the code snippet was updated and anything custom has been removed @AlexKasaku @michaellwest so it should be possible to reproduce. Thanks so far!
Definitely having some trouble consistently reproducing the issue. It happened for me once and then not again.
Can you confirm that the issue happens with this:
# Documentation : https://doc.sitecorepowershell.com/interfaces/interactive-dialogs
$options = [ordered]@{"OptionA"=1;"OptionB"=2;}
$optionTooltips = [ordered]@{1="Something interesting about A";2="Something interesting about B"}
$props = @{
Parameters = @(
@{Name="selectedOption"; Title="Choose an option"; Tooltip="Additional details about the option"; Options=$options; OptionTooltips=$optionTooltips; }
)
Title = "Option Selector"
Icon = "OfficeWhite/32x32/question.png"
Description = "Choose an option."
Width = 450
Height = 300
ShowHints = $true
}
$result = Read-Variable @props
if($result -eq "cancel"){
exit
}
@michaellwest I was able to reproduce with this code.
https://www.screencast.com/t/sCtpogVcyp
@michaellwest @AlexKasaku Can we provide you any further information or support?
Does this issue happen between two different users from different computers? For example User A is running the wizard and User B is publishing.
@michaellwest Yes this issue happen between two different users from different computers
@michaellwest @AlexKasaku The issue is occurring when two publishers are working simultaneously, which explains why it's a problem. We need to be capable of multiple publishers working at the same time. Any ideas as to what might be causing this?
Hi, I'm wondering if there is any more information I can provide for this, or how I can support a resolution.
happy newyear!
Since the module is open source you are free to investigate the issue, make code changes to troubleshoot, and submit a PR to address the issue for the larger community. Unfortunately it's not immediately known on what the proper fix is.
This seems to be SXA+SPE issue. There are SXA publish:end handlers that clear HttpRuntime cache and that affects SPE script session. Comment out/fix handlers below to address the issue
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.SitemapCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearSitemapCache" />
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.RobotsCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearRobotsCache" />
This seems to be SXA+SPE issue. There are SXA publish:end handlers that clear HttpRuntime cache and that affects SPE script session. Comment out/fix handlers below to address the issue
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.SitemapCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearSitemapCache" /> <handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.RobotsCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearRobotsCache" />
Thank you @lillchic, Issue fixed :)
I have comment out the below handlers in "Sitecore.XA.Feature.SiteMetadata.config"
<events>
<event name="publish:end">
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.SitemapCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearSitemapCache" />
</event>
<event name="publish:end:remote">
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.SitemapCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearSitemapCache" />
</event>
<event name="publish:end">
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.RobotsCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearRobotsCache" />
</event>
<event name="publish:end:remote">
<handler type="Sitecore.XA.Feature.SiteMetadata.EventHandlers.RobotsCacheClearer, Sitecore.XA.Feature.SiteMetadata" method="ClearRobotsCache" />
</event>
</events>