I had to use a variation of suggestions I'd found elsewhere to get this to work in VSCode. In my .zprofile I had to fence my long-running function with:
.zprofile
if [[ "$VSCODE_PID" = "" ]]; then DO THE THING... fi