How can I disconnect Construction script that crashes project? Or harvest last code?

UE4.27
I accidently saved the wrong version of an experimental Construction script, with a Loop break node. Now my project cant load.
I took the asset out of my Content folder, to save the Project (and it can load). But I want to salvage the last code changes. How can I do this? (Opening in textpad shows machine code.)

I was sleepy; made backups of the prior asset version. But:

  1. It was a loop of an array to cycle through the indexes, so I thought it couldnt endless loop. But I forgot to add the Break connection.

  2. I had the line to the main code disconnected while working on it (copied from BeginPlay code). I saved the code and didnt compile. But then I connected the line, saved again, which I shouldnt have done.

  3. So I dont have a backup of the copy before the Construct line was connected (but I made a lot of changes that I want to save).

  4. For future ref, are Loop with Break nodes ever able to be used in the Construction script? (I did it to save time. Im changing a set of 10 SK meshes to display, when I change a variable container. I think I need to use a loop to break the array, which contains the 10 sub variable settings.) Ty

1 Like

Hi XxNotAGamerxX,

You could remove it like you’ve done but put it in a subfolder somewhere else in your project - you should then be able to load it and edit it.

UE should timeout still with an “Infinite Loop” error though - you can control how many iterations that takes in your project preferences (search for infinite) - you could make that a very low number just to trap your construction script then change it back…

You should be able to use a “For Loop” from 0 to 9 without needing a break - or a “For Each Loop” on an Array - neither should infinite loop…

1 Like

Thanks! That’s what I was looking for, a disable loop setting per Engine, since I could not access the exact asset code.

“infinite” not found > search for “loop” . Do you want to edit your answer so I can pick it as the solution (to give you credit?) Otherwise I’ll use this to help others in the future:


Fix for infinite Construction loop that breaks project:

  1. Engine is stalled > Windows screenshot to remind you of where you were at.
  2. Force close Engine with Windows Task Manager (unsaved will be lost).

Long way (for fast way to skip step 3Fast not 3L):

3L. Windows > go to the folder that your Project is in > then goto the folder of the broken Asset. E.g.:

E:\UNREAL PROJECTS\MyProject01\Content\Pickups\ >> Bad.uasset file is in here.

4L. Cut this asset from the folder, go back to MyProject01 folder (i.e. get out of the Content directory), then paste it here.

E:\UNREAL PROJECTS\MyProject01

…
5L. Open the project (and this asset might be in the map file, thus fail to load, and show an error, but this is ok temporarily if you finish the steps).

6L. In UE, goto Project settings > search for “loop” > set to 1 (10 didnt work).

7L. Close UE, goto Windows project folder > copy Bad.uasset file back into your original location somewhere in the Content dir, e.g.:

E:\UNREAL PROJECTS\MyProject01\Content\Pickups\ >> Bad.uasset file goes back here.

8L. Load the project, it might load slower, but should stop loading the loop after 1 try, thus the project eventually loads (you’re saved > can access the Asset code now).


9L. Open the Bad asset to edit > goto Construction tab > disconnect the broken code and now Save! (so you can work on the fix but prevent the bad loop code from firing, or redoing the steps if Engine crashes again).
UE4 break Construct pin before compiling or saving untested code 3a

10L. For future ref, if working on untested Construction code: Disconnect the Construction pin BEFORE you save changes, and DO NOT compile (until you know that the code changes do not loop/crash). Then press play or compile >>

If the Engine locks, then force close the Editor, but you will not loose the last changes to your asset, and won’t be locked out of reloading the Editor because the fire pin (of the bad loop code) was disconnected.
UE4 break Construct pin before compiling or saving untested code 3b

11L. In UE, goto Project settings > search for “loop” > set back to something higher like 10000 [?] (edit: 100 or 1000 failed - made prior working scripts not work that didnt seem to need 1000 tries).

[End of steps]


Fast way (after steps 1-2 above):

3Fast. (The bad asset is still in the original Dir, but we cannot load the Project.) So in Windows > go to the folder that your Project is in > then goto its Config folder. E.g.:

E:\UNREAL PROJECTS\MyProject01\Config\

4F. Make a copy of “DefaultEngine.ini” > then open the original in Notepad (leave copy untouched as backup).

5F. Search for “engine.engine” to find the section called “[/Script/Engine.Engine]”
6F. Below that line, paste in this text without quotes:

MaximumLoopIterationCount=1

(this changes max loop from default of ~100000 to 1, without needing to open the broken project to change this setting).

…
7F. Now you can load the project. It might load slower, but should stop loading the flawed loop after 1 try, thus the project eventually loads (you’re saved > can access the Asset code now).

8F. Goto step 9L above for the final fixes and pic refs.

3 Likes

Mark yours as the answer - there’s some good info in there!

Thanks for directing me on how to find the answer :slight_smile:
The INI would not show me the setting until I changed it from default #.

1 Like